diff --git a/core/src/main/assets/messages/windows/windows.properties b/core/src/main/assets/messages/windows/windows.properties index c354622c5..e0b9ccf3d 100644 --- a/core/src/main/assets/messages/windows/windows.properties +++ b/core/src/main/assets/messages/windows/windows.properties @@ -5,6 +5,7 @@ windows.wndblacksmith.reforge=Reforge them windows.wndchallenges.title=Challenges windows.wndchooseability.message=The crown glows as it rests on your head, and both it and your armor become hot to the touch. You can feel the magic of the crown begin to act on your armor, but it must be directed. Which armor ability do you choose? +windows.wndchooseability.message_no_crown=Choose an ability for your armor! windows.wndchooseway.message=As the mask fits over your face, your eyesight fades and visions of new power flood into your mind. How will you direct the mask's power? windows.wndchooseway.cancel=I'll decide later diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/KingsCrown.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/KingsCrown.java index c1345000a..6b458499f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/KingsCrown.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/KingsCrown.java @@ -85,28 +85,32 @@ public class KingsCrown extends Item { public void upgradeArmor(Hero hero, Armor armor, ArmorAbility ability) { - detach( hero.belongings.backpack ); + detach(hero.belongings.backpack); - hero.sprite.centerEmitter().start( Speck.factory( Speck.KIT ), 0.05f, 10 ); + hero.sprite.centerEmitter().start(Speck.factory(Speck.KIT), 0.05f, 10); //TODO add a spell icon? - hero.spend( Actor.TICK ); + hero.spend(Actor.TICK); hero.busy(); - - GLog.p( Messages.get(this, "upgraded")); - - ClassArmor classArmor = ClassArmor.upgrade( hero, armor ); - if (hero.belongings.armor == armor) { - - curUser.belongings.armor = classArmor; - ((HeroSprite)curUser.sprite).updateArmor(); - classArmor.activate(curUser); - - } else { - - armor.detach( curUser.belongings.backpack ); - classArmor.collect( curUser.belongings.backpack ); - + + if (armor != null){ + + GLog.p(Messages.get(this, "upgraded")); + + ClassArmor classArmor = ClassArmor.upgrade(hero, armor); + if (hero.belongings.armor == armor) { + + curUser.belongings.armor = classArmor; + ((HeroSprite) curUser.sprite).updateArmor(); + classArmor.activate(curUser); + + } else { + + armor.detach(curUser.belongings.backpack); + classArmor.collect(curUser.belongings.backpack); + + } } + hero.armorAbility = ability; Talent.initArmorTalents(hero); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java index 8e059edc0..48b88817e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java @@ -26,7 +26,9 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndChooseAbility; import com.watabou.utils.Bundle; import java.util.ArrayList; @@ -34,7 +36,7 @@ import java.util.ArrayList; abstract public class ClassArmor extends Armor { private static final String AC_SPECIAL = "SPECIAL"; - //TODO heroes without an ability need to be able to choose one + private static final String AC_CHOOSE = "CHOOSE"; { levelKnown = true; @@ -129,6 +131,12 @@ abstract public class ClassArmor extends Armor { super.execute( hero, action ); if (action.equals(AC_SPECIAL)) { + + //for pre-0.9.3 saves + if (hero.armorAbility == null){ + GameScene.show(new WndChooseAbility(null, this, hero)); + return; + } if (!isEquipped( hero )) { GLog.w( Messages.get(this, "not_equipped") ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndChooseAbility.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndChooseAbility.java index 38718cc89..bab48c62f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndChooseAbility.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndChooseAbility.java @@ -41,14 +41,19 @@ public class WndChooseAbility extends Window { super(); + //crown can be null if hero is choosing from armor, pre-0.9.3 saves IconTitle titlebar = new IconTitle(); - titlebar.icon( new ItemSprite( crown.image(), null ) ); - titlebar.label( crown.name() ); + titlebar.icon( new ItemSprite( crown == null ? armor.image() : crown.image(), null ) ); + titlebar.label( Messages.titleCase(crown == null ? armor.name() : crown.name()) ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); RenderedTextBlock body = PixelScene.renderTextBlock( 6 ); - body.text( Messages.get(this, "message"), WIDTH ); + if (crown != null) { + body.text(Messages.get(this, "message"), WIDTH); + } else { + body.text(Messages.get(this, "message_no_crown"), WIDTH); + } body.setPos( titlebar.left(), titlebar.bottom() + GAP ); add( body ); @@ -60,7 +65,11 @@ public class WndChooseAbility extends Window { protected void onClick() { super.onClick(); hide(); - crown.upgradeArmor(hero, armor, ability); + if (crown != null) { + crown.upgradeArmor(hero, armor, ability); + } else { + new KingsCrown().upgradeArmor(hero, null, ability); + } } }; abilityButton.leftJustify = true;