v0.9.3: added functionality for ability selection for pre-0.9.3 saves

This commit is contained in:
Evan Debenham 2021-04-16 18:47:33 -04:00
parent 541d3105fd
commit 7972a5e271
4 changed files with 45 additions and 23 deletions

View File

@ -5,6 +5,7 @@ windows.wndblacksmith.reforge=Reforge them
windows.wndchallenges.title=Challenges 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=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.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 windows.wndchooseway.cancel=I'll decide later

View File

@ -85,28 +85,32 @@ public class KingsCrown extends Item {
public void upgradeArmor(Hero hero, Armor armor, ArmorAbility ability) { 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? //TODO add a spell icon?
hero.spend( Actor.TICK ); hero.spend(Actor.TICK);
hero.busy(); hero.busy();
GLog.p( Messages.get(this, "upgraded")); if (armor != null){
ClassArmor classArmor = ClassArmor.upgrade( hero, armor ); GLog.p(Messages.get(this, "upgraded"));
if (hero.belongings.armor == armor) {
curUser.belongings.armor = classArmor; ClassArmor classArmor = ClassArmor.upgrade(hero, armor);
((HeroSprite)curUser.sprite).updateArmor(); if (hero.belongings.armor == armor) {
classArmor.activate(curUser);
} else { curUser.belongings.armor = classArmor;
((HeroSprite) curUser.sprite).updateArmor();
classArmor.activate(curUser);
armor.detach( curUser.belongings.backpack ); } else {
classArmor.collect( curUser.belongings.backpack );
armor.detach(curUser.belongings.backpack);
classArmor.collect(curUser.belongings.backpack);
}
} }
hero.armorAbility = ability; hero.armorAbility = ability;
Talent.initArmorTalents(hero); Talent.initArmorTalents(hero);

View File

@ -26,7 +26,9 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal; import com.shatteredpixel.shatteredpixeldungeon.items.BrokenSeal;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndChooseAbility;
import com.watabou.utils.Bundle; import com.watabou.utils.Bundle;
import java.util.ArrayList; import java.util.ArrayList;
@ -34,7 +36,7 @@ import java.util.ArrayList;
abstract public class ClassArmor extends Armor { abstract public class ClassArmor extends Armor {
private static final String AC_SPECIAL = "SPECIAL"; 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; levelKnown = true;
@ -130,6 +132,12 @@ abstract public class ClassArmor extends Armor {
if (action.equals(AC_SPECIAL)) { 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 )) { if (!isEquipped( hero )) {
GLog.w( Messages.get(this, "not_equipped") ); GLog.w( Messages.get(this, "not_equipped") );
} else if (charge < 35) { } else if (charge < 35) {

View File

@ -41,14 +41,19 @@ public class WndChooseAbility extends Window {
super(); super();
//crown can be null if hero is choosing from armor, pre-0.9.3 saves
IconTitle titlebar = new IconTitle(); IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite( crown.image(), null ) ); titlebar.icon( new ItemSprite( crown == null ? armor.image() : crown.image(), null ) );
titlebar.label( crown.name() ); titlebar.label( Messages.titleCase(crown == null ? armor.name() : crown.name()) );
titlebar.setRect( 0, 0, WIDTH, 0 ); titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar ); add( titlebar );
RenderedTextBlock body = PixelScene.renderTextBlock( 6 ); 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 ); body.setPos( titlebar.left(), titlebar.bottom() + GAP );
add( body ); add( body );
@ -60,7 +65,11 @@ public class WndChooseAbility extends Window {
protected void onClick() { protected void onClick() {
super.onClick(); super.onClick();
hide(); hide();
crown.upgradeArmor(hero, armor, ability); if (crown != null) {
crown.upgradeArmor(hero, armor, ability);
} else {
new KingsCrown().upgradeArmor(hero, null, ability);
}
} }
}; };
abilityButton.leftJustify = true; abilityButton.leftJustify = true;