From 9c1cfc095fd768c320a347b63de555f1a1577464 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 26 Mar 2015 07:46:10 -0400 Subject: [PATCH] v0.3.0: wand types are now automatically known (wands still need to be IDed though) --- .../shatteredpixeldungeon/Badges.java | 13 +-- .../shatteredpixeldungeon/Dungeon.java | 4 - .../items/wands/Wand.java | 99 ++----------------- .../items/wands/WandOfMagicMissile.java | 9 -- .../items/wands/WandOfTeleportation.java | 3 +- 5 files changed, 17 insertions(+), 111 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java b/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java index 7907a78b3..a5cdb85c4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Badges.java @@ -463,9 +463,10 @@ public class Badges { validateAllItemsIdentified(); } } - - public static void validateAllWandsIdentified() { - if (Dungeon.hero != null && Dungeon.hero.isAlive() && + + //TODO: no longer in use, deal with new wand related badges in the badge rework. + /**public static void validateAllWandsIdentified() { + if (Dungeon.hero != null && Dungeon.hero.isAlive() && !local.contains( Badge.ALL_WANDS_IDENTIFIED ) && Wand.allKnown()) { Badge badge = Badge.ALL_WANDS_IDENTIFIED; @@ -474,7 +475,7 @@ public class Badges { validateAllItemsIdentified(); } - } + }*/ public static void validateAllBagsBought( Item bag ) { @@ -510,8 +511,8 @@ public class Badges { if (!global.contains( Badge.ALL_ITEMS_IDENTIFIED ) && global.contains( Badge.ALL_POTIONS_IDENTIFIED ) && global.contains( Badge.ALL_SCROLLS_IDENTIFIED ) && - global.contains( Badge.ALL_RINGS_IDENTIFIED ) && - global.contains( Badge.ALL_WANDS_IDENTIFIED )) { + global.contains( Badge.ALL_RINGS_IDENTIFIED )) { + //global.contains( Badge.ALL_WANDS_IDENTIFIED )) { Badge badge = Badge.ALL_ITEMS_IDENTIFIED; displayBadge( badge ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index d48b5c589..2b10c108c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -33,7 +33,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; -import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.levels.CavesBossLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.CavesLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.CityBossLevel; @@ -145,7 +144,6 @@ public class Dungeon { Scroll.initLabels(); Potion.initColors(); - Wand.initWoods(); Ring.initGems(); Statistics.reset(); @@ -452,7 +450,6 @@ public class Dungeon { Scroll.save( bundle ); Potion.save( bundle ); - Wand.save( bundle ); Ring.save( bundle ); Actor.storeNextID( bundle ); @@ -530,7 +527,6 @@ public class Dungeon { Scroll.restore( bundle ); Potion.restore( bundle ); - Wand.restore( bundle ); Ring.restore( bundle ); quickslot.restorePlaceholders( bundle ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java index 2ce3b35b6..bb6b8233c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; -import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; @@ -31,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile; import com.shatteredpixel.shatteredpixeldungeon.items.Item; -import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMagic.Magic; @@ -73,76 +71,20 @@ public abstract class Wand extends KindOfWeapon { private int usagesToKnow = USAGES_TO_KNOW; protected boolean hitChars = true; - - private static final Class[] wands = { - WandOfTeleportation.class, - WandOfSlowness.class, - WandOfFirebolt.class, - WandOfPoison.class, - WandOfRegrowth.class, - WandOfBlink.class, - WandOfLightning.class, - WandOfAmok.class, - WandOfTelekinesis.class, - WandOfFlock.class, - WandOfDisintegration.class, - WandOfAvalanche.class - }; - private static final String[] woods = - {"holly", "yew", "ebony", "cherry", "teak", "rowan", "willow", "mahogany", "bamboo", "purpleheart", "oak", "birch"}; - private static final Integer[] images = { - ItemSpriteSheet.WAND_HOLLY, - ItemSpriteSheet.WAND_YEW, - ItemSpriteSheet.WAND_EBONY, - ItemSpriteSheet.WAND_CHERRY, - ItemSpriteSheet.WAND_TEAK, - ItemSpriteSheet.WAND_ROWAN, - ItemSpriteSheet.WAND_WILLOW, - ItemSpriteSheet.WAND_MAHOGANY, - ItemSpriteSheet.WAND_BAMBOO, - ItemSpriteSheet.WAND_PURPLEHEART, - ItemSpriteSheet.WAND_OAK, - ItemSpriteSheet.WAND_BIRCH}; - - private static ItemStatusHandler handler; - - private String wood; + { defaultAction = AC_ZAP; - } - - @SuppressWarnings("unchecked") - public static void initWoods() { - handler = new ItemStatusHandler( (Class[])wands, woods, images ); - } - - public static void save( Bundle bundle ) { - handler.save( bundle ); - } - - @SuppressWarnings("unchecked") - public static void restore( Bundle bundle ) { - handler = new ItemStatusHandler( (Class[])wands, woods, images, bundle ); + + image = ItemSpriteSheet.WAND_MAGIC_MISSILE; } public Wand() { super(); calculateDamage(); - - try { - syncVisuals(); - } catch (Exception e) { - // Wand of Magic Missile - } - } - @Override - public void syncVisuals(){ - image = handler.image( this ); - wood = handler.label( this ); - } + } @Override public ArrayList actions( Hero hero ) { @@ -227,22 +169,9 @@ public abstract class Wand extends KindOfWeapon { } } - protected boolean isKnown() { - return handler.isKnown( this ); - } - - public void setKnown() { - if (!isKnown()) { - handler.know( this ); - } - - Badges.validateAllWandsIdentified(); - } - @Override public Item identify() { - - setKnown(); + curChargeKnown = true; super.identify(); @@ -264,14 +193,9 @@ public abstract class Wand extends KindOfWeapon { return sb.toString(); } - @Override - public String name() { - return isKnown() ? name : wood + " wand"; - } - @Override public String info() { - StringBuilder info = new StringBuilder( isKnown() ? desc() : String.format( TXT_WOOD, wood ) ); + StringBuilder info = new StringBuilder( desc() ); if (Dungeon.hero.heroClass == HeroClass.MAGE) { info.append( "\n\n" ); if (levelKnown) { @@ -285,7 +209,7 @@ public abstract class Wand extends KindOfWeapon { @Override public boolean isIdentified() { - return super.isIdentified() && isKnown() && curChargeKnown; + return super.isIdentified() && curChargeKnown; } @Override @@ -365,10 +289,6 @@ public abstract class Wand extends KindOfWeapon { return this; } - public static boolean allKnown() { - return handler.known().size() == wands.length; - } - @Override public int price() { int price = 75; @@ -431,9 +351,8 @@ public abstract class Wand extends KindOfWeapon { GLog.i( TXT_SELF_TARGET ); return; } - - curWand.setKnown(); - curUser.sprite.zap( cell ); + + curUser.sprite.zap(cell); //targets the enemy hit for char-hitting wands, or the cell aimed at for other wands. QuickSlotButton.target(Actor.findChar(curWand.hitChars ? cell : target)); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java index d531196b2..b695fc4c7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java @@ -107,15 +107,6 @@ public class WandOfMagicMissile extends Wand { } } - @Override - protected boolean isKnown() { - return true; - } - - @Override - public void setKnown() { - } - protected int initialCharges() { return 3; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfTeleportation.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfTeleportation.java index 8810f408a..884cb4ac7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfTeleportation.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfTeleportation.java @@ -40,8 +40,7 @@ public class WandOfTeleportation extends Wand { Char ch = Actor.findChar( cell ); if (ch == curUser) { - - setKnown(); + ScrollOfTeleportation.teleportHero( curUser ); } else if (ch != null && !(ch instanceof NPC)) {