From bc4dda1bf360faed8c7ba7e29759e5d62fa7eeec Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 28 Jun 2017 04:03:13 -0400 Subject: [PATCH] v0.6.1: more dried rose rework implementation --- .../items/artifacts/DriedRose.java | 107 ++++++++++++++++-- .../messages/items/items.properties | 11 +- 2 files changed, 109 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java index 8c394a97d..2a6339cdf 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java @@ -160,6 +160,10 @@ public class DriedRose extends Artifact { GameScene.show( new WndGhostHero(this) ); } } + + public int ghostStrength(){ + return 13 + level()/2; + } @Override public String desc() { @@ -771,29 +775,73 @@ public class DriedRose extends Artifact { private static class WndGhostHero extends Window{ - private static final int BTN_SIZE = 36; + private static final int BTN_SIZE = 32; private static final float GAP = 2; - private static final float BTN_GAP = 10; + private static final float BTN_GAP = 12; private static final int WIDTH = 116; private WndBlacksmith.ItemButton btnWeapon; private WndBlacksmith.ItemButton btnArmor; - WndGhostHero(DriedRose rose){ + WndGhostHero(final DriedRose rose){ IconTitle titlebar = new IconTitle(); titlebar.icon( new ItemSprite(rose) ); - titlebar.label( "Ghost's Equipment" ); + titlebar.label( Messages.get(this, "title") ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); - RenderedTextMultiline message = PixelScene.renderMultiline( "bleh", 6 ); + RenderedTextMultiline message = + PixelScene.renderMultiline(Messages.get(this, "desc", rose.ghostStrength()), 6); message.maxWidth( WIDTH ); message.setPos(0, titlebar.bottom() + GAP); add( message ); - btnWeapon = new WndBlacksmith.ItemButton(); - btnWeapon.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE ); + btnWeapon = new WndBlacksmith.ItemButton(){ + @Override + protected void onClick() { + if (rose.weapon != null){ + if (rose.weapon.doPickUp(Dungeon.hero)){ + item(new WndBag.Placeholder(ItemSpriteSheet.WEAPON_HOLDER)); + } else { + Dungeon.level.drop( rose.weapon, Dungeon.hero.pos); + } + rose.weapon = null; + } else { + GameScene.selectItem(new WndBag.Listener() { + @Override + public void onSelect(Item item) { + if (item.unique) { //catches boomerang + GLog.w( Messages.get(WndGhostHero.class, "cant_unique")); + hide(); + } else if (!(item instanceof MeleeWeapon)) { + //no message because this should never happen + hide(); + } else if (!item.isIdentified()) { + GLog.w( Messages.get(WndGhostHero.class, "cant_unidentified")); + hide(); + } else if (item.cursed) { + GLog.w( Messages.get(WndGhostHero.class, "cant_cursed")); + hide(); + } else if (((MeleeWeapon)item).STRReq() > rose.ghostStrength()) { + GLog.w( Messages.get(WndGhostHero.class, "cant_strength")); + hide(); + } else { + if (item.isEquipped(Dungeon.hero)){ + ((MeleeWeapon) item).doUnequip(Dungeon.hero, false, false); + } else { + item.detach(Dungeon.hero.belongings.backpack); + } + rose.weapon = (MeleeWeapon) item; + item(rose.weapon); + } + + } + }, WndBag.Mode.WEAPON, Messages.get(WndGhostHero.class, "weapon_prompt")); + } + } + }; + btnWeapon.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + GAP, BTN_SIZE, BTN_SIZE ); if (rose.weapon != null) { btnWeapon.item(rose.weapon); } else { @@ -801,7 +849,50 @@ public class DriedRose extends Artifact { } add( btnWeapon ); - btnArmor = new WndBlacksmith.ItemButton(); + btnArmor = new WndBlacksmith.ItemButton(){ + @Override + protected void onClick() { + if (rose.armor != null){ + if (rose.armor.doPickUp(Dungeon.hero)){ + item(new WndBag.Placeholder(ItemSpriteSheet.ARMOR_HOLDER)); + } else { + Dungeon.level.drop( rose.armor, Dungeon.hero.pos); + } + rose.armor = null; + } else { + GameScene.selectItem(new WndBag.Listener() { + @Override + public void onSelect(Item item) { + if (!(item instanceof Armor)) { + //no message because this should never happen + hide(); + } else if (item.unique || ((Armor) item).checkSeal() != null) { + GLog.w( Messages.get(WndGhostHero.class, "cant_unique")); + hide(); + } else if (!item.isIdentified()) { + GLog.w( Messages.get(WndGhostHero.class, "cant_unidentified")); + hide(); + } else if (item.cursed) { + GLog.w( Messages.get(WndGhostHero.class, "cant_cursed")); + hide(); + } else if (((Armor)item).STRReq() > rose.ghostStrength()) { + GLog.w( Messages.get(WndGhostHero.class, "cant_strength")); + hide(); + } else { + if (item.isEquipped(Dungeon.hero)){ + ((Armor) item).doUnequip(Dungeon.hero, false, false); + } else { + item.detach(Dungeon.hero.belongings.backpack); + } + rose.armor = (Armor) item; + item(rose.armor); + } + + } + }, WndBag.Mode.ARMOR, Messages.get(WndGhostHero.class, "armor_prompt")); + } + } + }; btnArmor.setRect( btnWeapon.right() + BTN_GAP, btnWeapon.top(), BTN_SIZE, BTN_SIZE ); if (rose.armor != null) { btnArmor.item(rose.armor); diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 977e83664..ec14a91b6 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -169,6 +169,7 @@ items.artifacts.cloakofshadows$cloakstealth.desc=Your cloak of shadows is granti items.artifacts.driedrose.name=dried rose items.artifacts.driedrose.ac_summon=SUMMON +items.artifacts.driedrose.ac_outfit=OUTFIT items.artifacts.driedrose.spawned=You have already summoned the ghost. items.artifacts.driedrose.no_charge=Your rose isn't fully charged yet. items.artifacts.driedrose.cursed=You cannot use a cursed rose. @@ -187,7 +188,15 @@ items.artifacts.driedrose$ghosthero.name=sad ghost items.artifacts.driedrose$ghosthero.def_verb=evaded items.artifacts.driedrose$ghosthero.hello=Hello again %s. items.artifacts.driedrose$ghosthero.introduce=My spirit is bound to this rose, it was very precious to me, a gift from my love whom I left on the surface.\n\nI cannot return to him, but thanks to you I have a second chance to complete my journey. When I am able I will respond to your call and fight with you.\n\nhopefully you may succeed where I failed... -items.artifacts.driedrose$ghosthero.desc=A frail looking ethereal figure with a humanoid shape. Its power seems tied to the rose I have.\n\nThis ghost may not be much, but it seems to be my only true friend down here. +items.artifacts.driedrose$ghosthero.desc=A frail looking ethereal figure with a humanoid shape. Its power seems tied to the rose you have.\n\nThis ghost may not be much, but it seems to be your only true friend down here. +items.artifacts.driedrose$wndghosthero.title=Ghost's Equipment +items.artifacts.driedrose$wndghosthero.desc=The ghost is weak on their own, but their form is solid enough to be equipped with a weapon and armor. They will be able to use these items just like you do.\n\nThe ghost can currently equip items requiring up to _%d strength._ +items.artifacts.driedrose$wndghosthero.weapon_prompt=Select a weapon +items.artifacts.driedrose$wndghosthero.armor_prompt=Select an armor +items.artifacts.driedrose$wndghosthero.cant_unique=The ghost can't use unique items. +items.artifacts.driedrose$wndghosthero.cant_unidentified=You don't know enough about that item. +items.artifacts.driedrose$wndghosthero.cant_cursed=You can't give the ghost cursed equipment. +items.artifacts.driedrose$wndghosthero.cant_strength=The ghost is not strong enough to use that. items.artifacts.etherealchains.name=ethereal chains items.artifacts.etherealchains.ac_cast=CAST