v3.1.0: added a new prompt to swap your seal when swapping armor

This commit is contained in:
Evan Debenham
2025-04-14 21:01:13 -04:00
parent c7a7cf8955
commit 809aef5f4d
3 changed files with 139 additions and 66 deletions

View File

@@ -93,6 +93,9 @@ items.armor.armor.cursed=You can feel a malevolent magic lurking within this arm
items.armor.armor.weak_cursed=Despite the curse, you are able to unequip this armor.
items.armor.armor.not_cursed=This armor is free of malevolent magic.
items.armor.armor.seal_attached=The Warrior's broken seal is attached to this armor. When he about to be injured below half health, it will grant him _%d shielding_.
items.armor.armor.seal_transfer=The Warrior's broken seal must be affixed to his currently worn armor in order to benefit him. Would you like to automatically detach the seal from the armor you are removing and affix it to the armor you are equipping?
items.armor.armor.seal_transfer_yes=yes
items.armor.armor.seal_transfer_no=no
items.armor.armor$glyph.glyph=glyph
items.armor.armor$glyph.killed=%s killed you...
items.armor.armor$glyph.rankings_desc=Killed by a glyph
@@ -2262,7 +2265,7 @@ 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 instantly gain shielding when he is about to be damaged to half health or lower.\n\nThe seal can be _affixed to armor,_ and moved between armors. It can carry a single upgrade with it, so long as that upgrade was applied to the armor while the seal was attached to it.
items.brokenseal.inscribed=The seal is inscribed with a _%s._
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.brokenseal.choose_desc=Both this armor and the broken seal are carrying a glyph. Pick which glyph should be kept.\n\nArmor Glyph: %1$s\nBroken Seal Glyph: %2$s\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.brokenseal.choose_curse_warn=_Your armor is cursed but your seal is not, so you cannot choose the seal's glyph!_
items.brokenseal.discover_hint=One of the heroes starts with this item.
items.brokenseal$warriorshield.name=Warrior Shield

View File

@@ -119,6 +119,77 @@ public class BrokenSeal extends Item {
}
}
//outgoing is either the seal itself as an item, or an armor the seal is affixed to
public void affixToArmor(Armor armor, Item outgoing){
if (armor != null) {
if (!armor.cursedKnown){
GLog.w(Messages.get(BrokenSeal.class, "unknown_armor"));
} else if (armor.glyph != null && getGlyph() != null
&& armor.glyph.getClass() != getGlyph().getClass()) {
//cannot apply the seal's non-curse glyph to a curse glyph armor
final boolean sealGlyphApplicable = !armor.glyph.curse() || getGlyph().curse();
String bodyText = Messages.get(BrokenSeal.class, "choose_desc", armor.glyph.name(), getGlyph().name());
if (!sealGlyphApplicable){
bodyText += "\n\n" + Messages.get(BrokenSeal.class, "choose_curse_warn");
}
GameScene.show(new WndOptions(new ItemSprite(ItemSpriteSheet.SEAL),
Messages.get(BrokenSeal.class, "choose_title"),
bodyText,
armor.glyph.name(),
getGlyph().name()){
@Override
protected void onSelect(int index) {
if (index == -1) return;
if (outgoing == BrokenSeal.this) {
detach(Dungeon.hero.belongings.backpack);
} else if (outgoing instanceof Armor){
((Armor) outgoing).detachSeal();
}
if (index == 0) 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.this);
}
@Override
protected boolean enabled(int index) {
if (index == 1 && !sealGlyphApplicable){
return false;
}
return super.enabled(index);
}
@Override
public void hide() {
super.hide();
Dungeon.hero.next();
}
});
} else {
if (outgoing == this) {
detach(Dungeon.hero.belongings.backpack);
} else if (outgoing instanceof Armor){
((Armor) outgoing).detachSeal();
}
GLog.p(Messages.get(BrokenSeal.class, "affix"));
Dungeon.hero.sprite.operate(Dungeon.hero.pos);
Sample.INSTANCE.play(Assets.Sounds.UNLOCK);
armor.affixSeal(this);
Dungeon.hero.next();
}
}
}
@Override
public String name() {
return glyph != null ? glyph.name( super.name() ) : super.name();
@@ -159,56 +230,9 @@ public class BrokenSeal extends Item {
@Override
public void onSelect( Item item ) {
BrokenSeal seal = (BrokenSeal) curItem;
if (item != null && item instanceof Armor) {
Armor armor = (Armor)item;
if (!armor.cursedKnown){
GLog.w(Messages.get(BrokenSeal.class, "unknown_armor"));
} else if (armor.glyph != null && seal.getGlyph() != null
&& armor.glyph.getClass() != seal.getGlyph().getClass()) {
//cannot apply the seal's non-curse glyph to a curse glyph armor
final boolean sealGlyphApplicable = !armor.glyph.curse() || seal.getGlyph().curse();
String bodyText = Messages.get(BrokenSeal.class, "choose_desc");
if (!sealGlyphApplicable){
bodyText += "\n\n" + Messages.get(BrokenSeal.class, "choose_curse_warn");
}
GameScene.show(new WndOptions(new ItemSprite(seal),
Messages.get(BrokenSeal.class, "choose_title"),
bodyText,
armor.glyph.name(),
seal.getGlyph().name()){
@Override
protected void onSelect(int index) {
if (index == -1) return;
if (index == 0) seal.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(seal);
seal.detach(Dungeon.hero.belongings.backpack);
}
@Override
protected boolean enabled(int index) {
if (index == 1 && !sealGlyphApplicable){
return false;
}
return super.enabled(index);
}
});
} else {
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);
}
if (item instanceof Armor) {
BrokenSeal seal = (BrokenSeal) curItem;
seal.affixToArmor((Armor)item, seal);
}
}
};

View File

@@ -68,10 +68,12 @@ import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.ParchmentScrap;
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.ShardOfOblivion;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.noosa.particles.Emitter;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
@@ -184,20 +186,7 @@ public class Armor extends EquipableItem {
super.execute(hero, action);
if (action.equals(AC_DETACH) && seal != null){
BrokenSeal.WarriorShield sealBuff = hero.buff(BrokenSeal.WarriorShield.class);
if (sealBuff != null) sealBuff.setArmor(null);
BrokenSeal detaching = seal;
seal = null;
if (detaching.level() > 0){
degrade();
}
if (detaching.canTransferGlyph()){
inscribe(null);
} else {
detaching.setGlyph(null);
}
BrokenSeal detaching = detachSeal();
GLog.i( Messages.get(Armor.class, "detach_seal") );
hero.sprite.operate(hero.pos);
if (!detaching.collect()){
@@ -251,6 +240,7 @@ public class Armor extends EquipableItem {
return false;
}
Armor oldArmor = hero.belongings.armor;
if (hero.belongings.armor == null || hero.belongings.armor.doUnequip( hero, true, false )) {
hero.belongings.armor = this;
@@ -264,7 +254,38 @@ public class Armor extends EquipableItem {
((HeroSprite)hero.sprite).updateArmor();
activate(hero);
Talent.onItemEquipped(hero, this);
hero.spendAndNext( timeToEquip( hero ) );
hero.spend( timeToEquip( hero ) );
if (Dungeon.hero.heroClass == HeroClass.WARRIOR && checkSeal() == null){
BrokenSeal seal = oldArmor != null ? oldArmor.checkSeal() : null;
if (seal != null){
GameScene.show(new WndOptions(new ItemSprite(ItemSpriteSheet.SEAL),
Messages.titleCase(seal.title()),
Messages.get(Armor.class, "seal_transfer"),
Messages.get(Armor.class, "seal_transfer_yes"),
Messages.get(Armor.class, "seal_transfer_no")){
@Override
protected void onSelect(int index) {
super.onSelect(index);
if (index == 0){
seal.affixToArmor(Armor.this, oldArmor);
updateQuickslot();
}
super.hide();
}
@Override
public void hide() {
//do nothing, must press button
}
});
} else {
hero.next();
}
} else {
hero.next();
}
return true;
} else {
@@ -296,6 +317,31 @@ public class Armor extends EquipableItem {
}
}
public BrokenSeal detachSeal(){
if (seal != null){
if (isEquipped(Dungeon.hero)) {
BrokenSeal.WarriorShield sealBuff = Dungeon.hero.buff(BrokenSeal.WarriorShield.class);
if (sealBuff != null) sealBuff.setArmor(null);
}
BrokenSeal detaching = seal;
seal = null;
if (detaching.level() > 0){
degrade();
}
if (detaching.canTransferGlyph()){
inscribe(null);
} else {
detaching.setGlyph(null);
}
return detaching;
} else {
return null;
}
}
public BrokenSeal checkSeal(){
return seal;
}