From 1182a13cef90c0f4e2dfa664c2315f8eecc8daaf Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 30 Nov 2020 12:44:50 -0500 Subject: [PATCH] v0.9.1: implemented the runic transference talent --- .../assets/messages/items/items.properties | 2 ++ .../items/BrokenSeal.java | 34 +++++++++++++++++++ .../items/armor/Armor.java | 19 +++++++++++ 3 files changed, 55 insertions(+) diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index 174c7c7ed..b34734ccc 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -1614,6 +1614,8 @@ items.brokenseal.unknown_armor=You must identify that armor first. items.brokenseal.degraded_armor=The condition of this armor is too poor. items.brokenseal.affix=You affix the seal to your armor! items.brokenseal.desc=A wax seal, affixed to armor as a symbol of valor. All the markings on the seal have worn off with age and it is broken in half down the middle.\n\nA memento from his home, the seal helps the warrior persevere. While wearing the seal the warrior will slowly generate shielding on top of his health based on the quality of his armor.\n\nThe seal can be _affixed to armor,_ and moved between armors. It can carry a single upgrade with it. +items.brokenseal.choose_title=Choose a Glyph +items.brokenseal.choose_desc=Both this armor and the broken seal are carrying a glyph. Pick which glyph should be kept.\n\nNote that if you pick the glyph that is currently on the armor, the seal will not be able to transfer it later. items.dewdrop.name=dewdrop items.dewdrop.value=%+dHP diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java index a51d3f4b8..86198e575 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java @@ -29,9 +29,11 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.shatteredpixel.shatteredpixeldungeon.windows.WndUseItem; import com.watabou.noosa.audio.Sample; @@ -54,6 +56,21 @@ public class BrokenSeal extends Item { defaultAction = AC_INFO; } + private Armor.Glyph glyph; + + public Armor.Glyph getGlyph(){ + return glyph; + } + + public void setGlyph( Armor.Glyph glyph ){ + this.glyph = glyph; + } + + @Override + public ItemSprite.Glowing glowing() { + return glyph != null ? glyph.glowing() : null; + } + @Override public ArrayList actions(Hero hero) { ArrayList actions = super.actions(hero); @@ -89,6 +106,23 @@ public class BrokenSeal extends Item { GLog.w(Messages.get(BrokenSeal.class, "unknown_armor")); } else if (armor.cursed || armor.level() < 0){ GLog.w(Messages.get(BrokenSeal.class, "degraded_armor")); + } else if (armor.glyph != null && ((BrokenSeal)curItem).getGlyph() != null) { + GameScene.show(new WndOptions(Messages.get(BrokenSeal.class, "choose_title"), + Messages.get(BrokenSeal.class, "choose_desc"), + armor.glyph.name(), + ((BrokenSeal)curItem).getGlyph().name()){ + @Override + protected void onSelect(int index) { + if (index == 0) ((BrokenSeal)curItem).setGlyph(null); + //if index is 1, then the glyph transfer happens in affixSeal + + GLog.p(Messages.get(BrokenSeal.class, "affix")); + Dungeon.hero.sprite.operate(Dungeon.hero.pos); + Sample.INSTANCE.play(Assets.Sounds.UNLOCK); + armor.affixSeal((BrokenSeal)curItem); + curItem.detach(Dungeon.hero.belongings.backpack); + } + }); } else { GLog.p(Messages.get(BrokenSeal.class, "affix")); Dungeon.hero.sprite.operate(Dungeon.hero.pos); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java index c1407b456..6c81af6b5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java @@ -173,6 +173,17 @@ public class Armor extends EquipableItem { if (seal.level() > 0){ degrade(); } + if (seal.getGlyph() != null){ + if (hero.hasTalent(Talent.RUNIC_TRANSFERENCE) + && Arrays.asList(Glyph.common).contains(seal.getGlyph().getClass())){ + inscribe(null); + } else if (hero.pointsInTalent(Talent.RUNIC_TRANSFERENCE) == 2 + && Arrays.asList(Glyph.uncommon).contains(seal.getGlyph().getClass())){ + inscribe(null); + } else { + seal.setGlyph(null); + } + } GLog.i( Messages.get(Armor.class, "detach_seal") ); hero.sprite.operate(hero.pos); if (!seal.collect()){ @@ -223,6 +234,9 @@ public class Armor extends EquipableItem { level(level()+1); Badges.validateItemLevelAquired(this); } + if (seal.getGlyph() != null){ + inscribe(seal.getGlyph()); + } if (isEquipped(Dungeon.hero)){ Buff.affect(Dungeon.hero, BrokenSeal.WarriorShield.class).setArmor(this); } @@ -542,6 +556,11 @@ public class Armor extends EquipableItem { if (glyph == null || !glyph.curse()) curseInfusionBonus = false; this.glyph = glyph; updateQuickslot(); + //the hero needs runic transference to actually transfer, but we still attach the glyph here + // in case they take that talent in the future + if (glyph != null && seal != null){ + seal.setGlyph(glyph); + } return this; }