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

This commit is contained in:
Evan Debenham 2015-05-12 22:15:31 -04:00
parent 0a78b2dc28
commit 00dc49c021
5 changed files with 33 additions and 120 deletions

View File

@ -76,10 +76,20 @@ public class Belongings implements Iterable<Item> {
backpack.clear();
backpack.restoreFromBundle( bundle );
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 );

View File

@ -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 );

View File

@ -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<String> actions( Hero hero ) {
ArrayList<String> 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 );
@ -382,7 +344,6 @@ public abstract class Wand extends KindOfWeapon {
} else {
curUser.spendAndNext( TIME_TO_ZAP );
GLog.w( TXT_FIZZLES );
}

View File

@ -44,15 +44,6 @@ 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<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (level > 0) {
actions.add( AC_DISENCHANT );
}
return actions;
}
@Override
protected void onZap( Ballistica bolt ) {
@ -95,29 +77,6 @@ public class WandOfMagicMissile extends Wand {
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 );
}
}
}
};
}

View File

@ -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();
}