v0.9.2: fixed cloak unequiping and save/load errors

This commit is contained in:
Evan Debenham 2021-02-19 23:06:53 -05:00
parent a20df5c724
commit 54a85767de

View File

@ -64,15 +64,13 @@ public class CloakOfShadows extends Artifact {
bones = false; bones = false;
} }
private boolean stealthed = false;
public static final String AC_STEALTH = "STEALTH"; public static final String AC_STEALTH = "STEALTH";
@Override @Override
public ArrayList<String> actions( Hero hero ) { public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero ); ArrayList<String> actions = super.actions( hero );
if ((isEquipped( hero ) || hero.hasTalent(Talent.LIGHT_CLOAK)) if ((isEquipped( hero ) || hero.hasTalent(Talent.LIGHT_CLOAK))
&& !cursed && (charge > 0 || stealthed)) { && !cursed && (charge > 0 || activeBuff != null)) {
actions.add(AC_STEALTH); actions.add(AC_STEALTH);
} }
return actions; return actions;
@ -85,12 +83,11 @@ public class CloakOfShadows extends Artifact {
if (action.equals( AC_STEALTH )) { if (action.equals( AC_STEALTH )) {
if (!stealthed){ if (activeBuff == null){
if (!isEquipped(hero) && !hero.hasTalent(Talent.LIGHT_CLOAK)) GLog.i( Messages.get(Artifact.class, "need_to_equip") ); if (!isEquipped(hero) && !hero.hasTalent(Talent.LIGHT_CLOAK)) GLog.i( Messages.get(Artifact.class, "need_to_equip") );
else if (cursed) GLog.i( Messages.get(this, "cursed") ); else if (cursed) GLog.i( Messages.get(this, "cursed") );
else if (charge <= 0) GLog.i( Messages.get(this, "no_charge") ); else if (charge <= 0) GLog.i( Messages.get(this, "no_charge") );
else { else {
stealthed = true;
hero.spend( 1f ); hero.spend( 1f );
hero.busy(); hero.busy();
Sample.INSTANCE.play(Assets.Sounds.MELD); Sample.INSTANCE.play(Assets.Sounds.MELD);
@ -105,7 +102,6 @@ public class CloakOfShadows extends Artifact {
hero.sprite.operate(hero.pos); hero.sprite.operate(hero.pos);
} }
} else { } else {
stealthed = false;
activeBuff.detach(); activeBuff.detach();
activeBuff = null; activeBuff = null;
hero.spend( 1f ); hero.spend( 1f );
@ -118,8 +114,7 @@ public class CloakOfShadows extends Artifact {
@Override @Override
public void activate(Char ch){ public void activate(Char ch){
super.activate(ch); super.activate(ch);
if (stealthed){ if (activeBuff != null){
activeBuff = activeBuff();
activeBuff.attachTo(ch); activeBuff.attachTo(ch);
} }
} }
@ -127,7 +122,6 @@ public class CloakOfShadows extends Artifact {
@Override @Override
public boolean doUnequip(Hero hero, boolean collect, boolean single) { public boolean doUnequip(Hero hero, boolean collect, boolean single) {
if (super.doUnequip(hero, collect, single)){ if (super.doUnequip(hero, collect, single)){
stealthed = false;
if (hero.hasTalent(Talent.LIGHT_CLOAK)){ if (hero.hasTalent(Talent.LIGHT_CLOAK)){
activate(hero); activate(hero);
} }
@ -141,6 +135,7 @@ public class CloakOfShadows extends Artifact {
public boolean collect( Bag container ) { public boolean collect( Bag container ) {
if (super.collect(container)){ if (super.collect(container)){
if (container.owner instanceof Hero if (container.owner instanceof Hero
&& passiveBuff == null
&& ((Hero) container.owner).hasTalent(Talent.LIGHT_CLOAK)){ && ((Hero) container.owner).hasTalent(Talent.LIGHT_CLOAK)){
activate((Hero) container.owner); activate((Hero) container.owner);
} }
@ -167,7 +162,6 @@ public class CloakOfShadows extends Artifact {
return new cloakRecharge(); return new cloakRecharge();
} }
//FIXME errors with this!
@Override @Override
protected ArtifactBuff activeBuff( ) { protected ArtifactBuff activeBuff( ) {
return new cloakStealth(); return new cloakStealth();
@ -197,17 +191,21 @@ public class CloakOfShadows extends Artifact {
} }
private static final String STEALTHED = "stealthed"; private static final String STEALTHED = "stealthed";
private static final String BUFF = "buff";
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle(bundle); super.storeInBundle(bundle);
bundle.put( STEALTHED, stealthed ); if (activeBuff != null) bundle.put(BUFF, activeBuff);
} }
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle(bundle); super.restoreFromBundle(bundle);
stealthed = bundle.getBoolean( STEALTHED ); if (bundle.contains(BUFF)){
activeBuff = new cloakStealth();
activeBuff.restoreFromBundle(bundle.getBundle(BUFF));
}
} }
@Override @Override
@ -220,7 +218,7 @@ public class CloakOfShadows extends Artifact {
public boolean act() { public boolean act() {
if (charge < chargeCap) { if (charge < chargeCap) {
LockedFloor lock = target.buff(LockedFloor.class); LockedFloor lock = target.buff(LockedFloor.class);
if (!stealthed && (lock == null || lock.regenOn())) { if (activeBuff == null && (lock == null || lock.regenOn())) {
float missing = (chargeCap - charge); float missing = (chargeCap - charge);
if (level() > 7) missing += 5*(level() - 7)/3f; if (level() > 7) missing += 5*(level() - 7)/3f;
float turnsToCharge = (45 - missing); float turnsToCharge = (45 - missing);
@ -363,9 +361,7 @@ public class CloakOfShadows extends Artifact {
@Override @Override
public void detach() { public void detach() {
if (target.invisible > 0) if (target.invisible > 0) target.invisible--;
target.invisible--;
stealthed = false;
updateQuickslot(); updateQuickslot();
super.detach(); super.detach();