From c96966f54df19ccaa00423bcacf52548eac2d435 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 13 May 2016 16:24:31 -0400 Subject: [PATCH] v0.4.0: refactored artifacts storing their image reference --- .../items/artifacts/Artifact.java | 2 -- .../items/artifacts/ChaliceOfBlood.java | 8 +++++++ .../items/artifacts/HornOfPlenty.java | 22 +++++++++++-------- .../items/artifacts/SandalsOfNature.java | 15 ++++++------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java index e8dbfd4f5..7d033632f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java @@ -241,7 +241,6 @@ public class Artifact extends KindofMisc { @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle(bundle); - bundle.put( IMAGE, image ); bundle.put( EXP , exp ); bundle.put( CHARGE , charge ); bundle.put( PARTIALCHARGE , partialCharge ); @@ -250,7 +249,6 @@ public class Artifact extends KindofMisc { @Override public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle(bundle); - if (bundle.contains( IMAGE )) image = bundle.getInt( IMAGE ); exp = bundle.getInt( EXP ); charge = bundle.getInt( CHARGE ); partialCharge = bundle.getFloat( PARTIALCHARGE ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java index 4fffac509..364a7efb6 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/ChaliceOfBlood.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.watabou.noosa.audio.Sample; +import com.watabou.utils.Bundle; import com.watabou.utils.Random; import java.util.ArrayList; @@ -123,6 +124,13 @@ public class ChaliceOfBlood extends Artifact { return super.upgrade(); } + @Override + public void restoreFromBundle(Bundle bundle) { + super.restoreFromBundle(bundle); + if (level() >= 7) image = ItemSpriteSheet.ARTIFACT_CHALICE3; + else if (level() >= 3) image = ItemSpriteSheet.ARTIFACT_CHALICE2; + } + @Override protected ArtifactBuff passiveBuff() { return new chaliceRegen(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java index 0b336a281..1bbcbe552 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java @@ -41,6 +41,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; import com.watabou.noosa.audio.Sample; +import com.watabou.utils.Bundle; import java.util.ArrayList; @@ -154,6 +155,14 @@ public class HornOfPlenty extends Artifact { return desc; } + @Override + public void restoreFromBundle(Bundle bundle) { + super.restoreFromBundle(bundle); + if (charge == chargeCap)image = ItemSpriteSheet.ARTIFACT_HORN4; + else if (charge >= 7) image = ItemSpriteSheet.ARTIFACT_HORN3; + else if (charge >= 3) image = ItemSpriteSheet.ARTIFACT_HORN2; + } + public class hornRecharge extends ArtifactBuff{ @Override @@ -170,14 +179,10 @@ public class HornOfPlenty extends Artifact { charge++; partialCharge -= 36; - if (charge == chargeCap) - image = ItemSpriteSheet.ARTIFACT_HORN4; - else if (charge >= 7) - image = ItemSpriteSheet.ARTIFACT_HORN3; - else if (charge >= 3) - image = ItemSpriteSheet.ARTIFACT_HORN2; - else - image = ItemSpriteSheet.ARTIFACT_HORN1; + if (charge == chargeCap)image = ItemSpriteSheet.ARTIFACT_HORN4; + else if (charge >= 7) image = ItemSpriteSheet.ARTIFACT_HORN3; + else if (charge >= 3) image = ItemSpriteSheet.ARTIFACT_HORN2; + else image = ItemSpriteSheet.ARTIFACT_HORN1; if (charge == chargeCap){ GLog.p( Messages.get(HornOfPlenty.class, "full") ); @@ -220,5 +225,4 @@ public class HornOfPlenty extends Artifact { } } }; - } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java index 413ca41c9..af20c7d60 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java @@ -124,14 +124,10 @@ public class SandalsOfNature extends Artifact { @Override public Item upgrade() { - if (level() < 0) - image = ItemSpriteSheet.ARTIFACT_SANDALS; - else if (level() == 0) - image = ItemSpriteSheet.ARTIFACT_SHOES; - else if (level() == 1) - image = ItemSpriteSheet.ARTIFACT_BOOTS; - else if (level() >= 2) - image = ItemSpriteSheet.ARTIFACT_GREAVES; + if (level() < 0) image = ItemSpriteSheet.ARTIFACT_SANDALS; + else if (level() == 0) image = ItemSpriteSheet.ARTIFACT_SHOES; + else if (level() == 1) image = ItemSpriteSheet.ARTIFACT_BOOTS; + else if (level() >= 2) image = ItemSpriteSheet.ARTIFACT_GREAVES; name = Messages.get(this, "name_" + (level()+1)); return super.upgrade(); } @@ -151,6 +147,9 @@ public class SandalsOfNature extends Artifact { if (level() > 0) name = Messages.get(this, "name_" + level()); if (bundle.contains(SEEDS)) Collections.addAll(seeds , bundle.getClassArray(SEEDS)); + if (level() == 1) image = ItemSpriteSheet.ARTIFACT_SHOES; + else if (level() == 2) image = ItemSpriteSheet.ARTIFACT_BOOTS; + else if (level() >= 3) image = ItemSpriteSheet.ARTIFACT_GREAVES; } public class Naturalism extends ArtifactBuff{