From 00dc49c0218c9ad8f712b1bd1e5f7cd2dad61422 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 12 May 2015 22:15:31 -0400 Subject: [PATCH] v0.3.0: removed the ability to disenchant the wand of magic missile, removed wands as weapons, added save transfer logic for pre-0.3.0 --- .../actors/hero/Belongings.java | 18 ++++- .../actors/hero/Hero.java | 2 +- .../items/wands/Wand.java | 47 +----------- .../items/wands/WandOfMagicMissile.java | 73 +------------------ .../scenes/GameScene.java | 13 ++++ 5 files changed, 33 insertions(+), 120 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java index ff64da7a0..a48da7014 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Belongings.java @@ -75,10 +75,20 @@ public class Belongings implements Iterable { backpack.clear(); backpack.restoreFromBundle( bundle ); - - weapon = (KindOfWeapon)bundle.get( WEAPON ); - if (weapon != null) { - weapon.activate( owner ); + + if (bundle.get( WEAPON ) instanceof Wand){ + //handles the case of an equipped wand from pre-0.3.0 + Wand item = (Wand) bundle.get(WEAPON); + //try to add the wand to inventory + if (!item.collect(backpack)){ + //if it's too full, shove it in anyway + backpack.items.add(item); + } + } else { + weapon = (KindOfWeapon) bundle.get(WEAPON); + if (weapon != null) { + weapon.activate(owner); + } } armor = (Armor)bundle.get( ARMOR ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 259e8e3e3..ccd69b044 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -869,7 +869,7 @@ public class Hero extends Char { } break; case BATTLEMAGE: - if (wep instanceof Wand || wep instanceof MagesStaff) { + if (wep instanceof MagesStaff) { //gives wands 50% charge Buff.affect( this, ScrollOfRecharging.Recharging.class, 2f); ScrollOfRecharging.charge( this ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java index 1e6d2a793..e041ced64 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/Wand.java @@ -44,7 +44,7 @@ import com.watabou.utils.Bundle; import com.watabou.utils.Callback; import com.watabou.utils.Random; -public abstract class Wand extends KindOfWeapon { +public abstract class Wand extends Item { private static final int USAGES_TO_KNOW = 10; @@ -78,37 +78,16 @@ public abstract class Wand extends KindOfWeapon { defaultAction = AC_ZAP; } - public Wand() { - super(); - - calculateDamage(); - - } - @Override public ArrayList actions( Hero hero ) { ArrayList actions = super.actions( hero ); if (curCharges > 0 || !curChargeKnown) { actions.add( AC_ZAP ); } - if (hero.heroClass != HeroClass.MAGE) { - actions.remove( AC_EQUIP ); - actions.remove( AC_UNEQUIP ); - } + return actions; } - @Override - public boolean doUnequip( Hero hero, boolean collect, boolean single ) { - onDetach(); - return super.doUnequip( hero, collect, single ); - } - - @Override - public void activate( Hero hero ) { - charge( hero ); - } - @Override public void execute( Hero hero, String action ) { if (action.equals( AC_ZAP )) { @@ -196,16 +175,7 @@ public abstract class Wand extends KindOfWeapon { @Override public String info() { - StringBuilder info = new StringBuilder( desc() ); - if (Dungeon.hero.heroClass == HeroClass.MAGE) { - info.append( "\n\n" ); - if (levelKnown) { - info.append( String.format( TXT_DAMAGE, MIN + (MAX - MIN) / 2 ) ); - } else { - info.append( String.format( TXT_WEAPON ) ); - } - } - return info.toString(); + return desc(); } @Override @@ -247,8 +217,6 @@ public abstract class Wand extends KindOfWeapon { public void updateLevel() { maxCharges = Math.min( initialCharges() + level, 10 ); curCharges = Math.min( curCharges, maxCharges ); - - calculateDamage(); } protected int initialCharges() { @@ -259,12 +227,6 @@ public abstract class Wand extends KindOfWeapon { return 1; } - private void calculateDamage() { - int tier = 1 + level / 3; - MIN = tier; - MAX = (tier * tier - tier + 10) / 2 + level; - } - protected void fx( Ballistica bolt, Callback callback ) { MagicMissile.whiteLight( curUser.sprite.parent, bolt.sourcePos, bolt.collisionPos, callback ); Sample.INSTANCE.play( Assets.SND_ZAP ); @@ -381,8 +343,7 @@ public abstract class Wand extends KindOfWeapon { Invisibility.dispel(); } else { - - curUser.spendAndNext( TIME_TO_ZAP ); + GLog.w( TXT_FIZZLES ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java index 9dd3ecedc..5766f6103 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfMagicMissile.java @@ -43,16 +43,7 @@ import java.util.ArrayList; public class WandOfMagicMissile extends Wand { public static final String AC_DISENCHANT = "DISENCHANT"; - - private static final String TXT_SELECT_WAND = "Select a wand to upgrade"; - - private static final String TXT_DISENCHANTED = - "you disenchanted the Wand of Magic Missile and used its essence to upgrade your %s"; - - private static final float TIME_TO_DISENCHANT = 2f; - - private boolean disenchantEquipped; - + { name = "Wand of Magic Missile"; image = ItemSpriteSheet.WAND_MAGIC_MISSILE; @@ -60,15 +51,6 @@ public class WandOfMagicMissile extends Wand { bones = false; } - @Override - public ArrayList actions( Hero hero ) { - ArrayList actions = super.actions( hero ); - if (level > 0) { - actions.add( AC_DISENCHANT ); - } - return actions; - } - @Override protected void onZap( Ballistica bolt ) { @@ -94,29 +76,6 @@ public class WandOfMagicMissile extends Wand { partialCharge += ((maxCharges - curCharges)/20f)*staff.level; SpellSprite.show(attacker, SpellSprite.CHARGE); } - - @Override - public void execute( Hero hero, String action ) { - if (action.equals( AC_DISENCHANT )) { - - if (hero.belongings.weapon == this) { - disenchantEquipped = true; - hero.belongings.weapon = null; - updateQuickslot(); - } else { - disenchantEquipped = false; - detach( hero.belongings.backpack ); - } - - curUser = hero; - GameScene.selectItem( itemSelector, WndBag.Mode.WAND, TXT_SELECT_WAND ); - - } else { - - super.execute( hero, action ); - - } - } protected int initialCharges() { return 4; @@ -127,34 +86,4 @@ public class WandOfMagicMissile extends Wand { return "This wand launches missiles of pure magical energy, dealing moderate damage to a target creature."; } - - private final WndBag.Listener itemSelector = new WndBag.Listener() { - @Override - public void onSelect( Item item ) { - if (item != null) { - - Sample.INSTANCE.play( Assets.SND_EVOKE ); - ScrollOfUpgrade.upgrade( curUser ); - evoke( curUser ); - - GLog.w( TXT_DISENCHANTED, item.name() ); - - Dungeon.quickslot.clearItem(WandOfMagicMissile.this); - WandOfMagicMissile.this.updateQuickslot(); - - item.upgrade(); - curUser.spendAndNext( TIME_TO_DISENCHANT ); - - Badges.validateItemLevelAquired( item ); - - } else { - if (disenchantEquipped) { - curUser.belongings.weapon = WandOfMagicMissile.this; - WandOfMagicMissile.this.updateQuickslot(); - } else { - collect( curUser.belongings.backpack ); - } - } - } - }; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index 3a9da11a2..36bbf3e58 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -21,12 +21,14 @@ import java.io.IOException; import java.util.ArrayList; import com.shatteredpixel.shatteredpixeldungeon.*; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot; import com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier; import com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder; import com.shatteredpixel.shatteredpixeldungeon.items.bags.SeedPouch; import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.ResumeIndicator; import com.watabou.noosa.Camera; @@ -332,6 +334,17 @@ public class GameScene extends PixelScene { Dungeon.droppedItems.remove( Dungeon.depth ); } + + //logic for pre 0.3.0 saves, need to give mages a staff. + if (Dungeon.version <= 38 && Dungeon.hero.heroClass == HeroClass.MAGE){ + MagesStaff staff = new MagesStaff(); + staff.identify(); + GLog.p("You have been given a mage's staff, imbue it with a wand!"); + if (!staff.collect(Dungeon.hero.belongings.backpack)){ + Dungeon.level.drop(staff, Dungeon.hero.pos); + } + } + Camera.main.target = hero; fadeIn(); }