From b851be162eb9e342efc88aa13c95c1db58e6b0c7 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 9 Dec 2014 16:40:36 -0500 Subject: [PATCH] v0.2.3: quickslot refactoring for artifacts --- .../items/artifacts/CloakOfShadows.java | 11 ++- .../items/artifacts/DriedRose.java | 35 +++++----- .../items/artifacts/HornOfPlenty.java | 69 ++++++++++--------- .../items/artifacts/SandalsOfNature.java | 15 ++-- .../items/artifacts/TalismanOfForesight.java | 38 +++++----- .../items/artifacts/UnstableSpellbook.java | 2 + 6 files changed, 94 insertions(+), 76 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakOfShadows.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakOfShadows.java index 0cca8c8a6..908b6e5a4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakOfShadows.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/CloakOfShadows.java @@ -57,7 +57,10 @@ public class CloakOfShadows extends Artifact { if (action.equals( AC_STEALTH )) { if (!stealthed){ - if (cooldown <= 0 && charge >= 2 && isEquipped(hero)) { + if (!isEquipped(hero)) GLog.i("You need to equip your cloak to do that."); + else if (cooldown > 0) GLog.i("Your cloak needs " + cooldown + " more rounds to re-energize."); + else if (charge <= 1) GLog.i("Your cloak hasn't recharged enough to be usable yet."); + else { stealthed = true; hero.spend( 1f ); hero.busy(); @@ -71,12 +74,6 @@ public class CloakOfShadows extends Artifact { } hero.sprite.operate(hero.pos); GLog.i("Your cloak blends you into the shadows."); - } else if (!isEquipped(hero)) { - GLog.i("You need to equip your cloak to do that."); - } else if (cooldown > 0) { - GLog.i("Your cloak needs " + cooldown + " more rounds to re-energize."); - } else if (charge <= 1){ - GLog.i("Your cloak hasn't recharged enough to be usable yet."); } } else { stealthed = false; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java index 8407ed65e..922cfb0bb 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/DriedRose.java @@ -9,16 +9,13 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; -import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; -import com.shatteredpixel.shatteredpixeldungeon.sprites.GhostSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.WraithSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Random; @@ -59,26 +56,30 @@ public class DriedRose extends Artifact { public void execute( Hero hero, String action ) { if (action.equals(AC_SUMMON)) { - ArrayList spawnPoints = new ArrayList(); - for (int i=0; i < Level.NEIGHBOURS8.length; i++) { - int p = hero.pos + Level.NEIGHBOURS8[i]; - if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) { - spawnPoints.add( p ); + if (!isEquipped( hero )) GLog.i("You need to equip your rose to do that."); + else if (charge != chargeCap) GLog.i("Your rose isn't fully charged yet."); + else { + ArrayList spawnPoints = new ArrayList(); + for (int i = 0; i < Level.NEIGHBOURS8.length; i++) { + int p = hero.pos + Level.NEIGHBOURS8[i]; + if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) { + spawnPoints.add(p); + } } - } - if (spawnPoints.size() > 0) { - GhostHero ghost = new GhostHero(); - ghost.pos = Random.element(spawnPoints); + if (spawnPoints.size() > 0) { + GhostHero ghost = new GhostHero(); + ghost.pos = Random.element(spawnPoints); - GameScene.add( ghost, 1f ); - CellEmitter.get(ghost.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); + GameScene.add(ghost, 1f); + CellEmitter.get(ghost.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); - hero.spend( 1f ); - hero.busy(); - hero.sprite.operate(hero.pos); + hero.spend(1f); + hero.busy(); + hero.sprite.operate(hero.pos); + } } } else{ diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java index 72ffb5570..908ee94cd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java @@ -34,6 +34,8 @@ public class HornOfPlenty extends Artifact { levelCap = 30; charge = 0; chargeCap = 10; + + defaultAction = AC_EAT; } private static final float TIME_TO_EAT = 3f; @@ -63,41 +65,46 @@ public class HornOfPlenty extends Artifact { super.execute(hero, action); if (action.equals(AC_EAT)){ - ((Hunger)hero.buff( Hunger.class )).satisfy( energy*charge ); - //if you get at least 100 food energy from the horn - if (charge >= 3){ - switch (hero.heroClass) { - case WARRIOR: - if (hero.HP < hero.HT) { - hero.HP = Math.min( hero.HP + 5, hero.HT ); - hero.sprite.emitter().burst( Speck.factory(Speck.HEALING), 1 ); - } - break; - case MAGE: - hero.belongings.charge( false ); - ScrollOfRecharging.charge(hero); - break; - case ROGUE: - case HUNTRESS: - break; + if (!isEquipped(hero)) GLog.i("You need to equip your horn to do that."); + else if (charge == 0) GLog.i("Your horn has no food in it to eat!"); + else { + ((Hunger) hero.buff(Hunger.class)).satisfy(energy * charge); + + //if you get at least 100 food energy from the horn + if (charge >= 3) { + switch (hero.heroClass) { + case WARRIOR: + if (hero.HP < hero.HT) { + hero.HP = Math.min(hero.HP + 5, hero.HT); + hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1); + } + break; + case MAGE: + hero.belongings.charge(false); + ScrollOfRecharging.charge(hero); + break; + case ROGUE: + case HUNTRESS: + break; + } + + Statistics.foodEaten++; } + charge = 0; - Statistics.foodEaten++; + hero.sprite.operate(hero.pos); + hero.busy(); + SpellSprite.show(hero, SpellSprite.FOOD); + Sample.INSTANCE.play(Assets.SND_EAT); + GLog.i("You eat from the horn."); + + hero.spend(TIME_TO_EAT); + + Badges.validateFoodEaten(); + + image = ItemSpriteSheet.ARTIFACT_HORN1; } - charge = 0; - - hero.sprite.operate( hero.pos ); - hero.busy(); - SpellSprite.show(hero, SpellSprite.FOOD); - Sample.INSTANCE.play( Assets.SND_EAT ); - GLog.i("You eat from the horn."); - - hero.spend( TIME_TO_EAT ); - - Badges.validateFoodEaten(); - - image = ItemSpriteSheet.ARTIFACT_HORN1; } else if (action.equals(AC_STORE)){ diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java index 3638f5f7a..846a5f4b5 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/SandalsOfNature.java @@ -32,6 +32,8 @@ public class SandalsOfNature extends Artifact { levelCap = 3; charge = 0; //partialcharge, chargeCap and exp are unused + + defaultAction = AC_ROOT; } public static final String[] NAMES = {"Sandals of Nature", "Shoes of Nature", @@ -60,12 +62,15 @@ public class SandalsOfNature extends Artifact { super.execute(hero, action); if (action.equals(AC_FEED)){ GameScene.selectItem(itemSelector, mode, inventoryTitle); - } else if (action.equals(AC_ROOT)){ - if (charge > 0){ - Buff.prolong( hero, Roots.class, 5); - Buff.affect( hero, Earthroot.Armor.class ).level( charge ); + } else if (action.equals(AC_ROOT) && level > 0){ + + if (!isEquipped( hero )) GLog.i("You need to equip them to do that."); + else if (charge == 0) GLog.i("They have no energy right now."); + else { + Buff.prolong(hero, Roots.class, 5); + Buff.affect(hero, Earthroot.Armor.class).level(charge); CellEmitter.bottom(hero.pos).start(EarthParticle.FACTORY, 0.05f, 8); - Camera.main.shake( 1, 0.4f ); + Camera.main.shake(1, 0.4f); charge = 0; } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TalismanOfForesight.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TalismanOfForesight.java index bba8891ec..4033fe566 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TalismanOfForesight.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/TalismanOfForesight.java @@ -30,6 +30,8 @@ public class TalismanOfForesight extends Artifact { exp = 0; partialCharge = 0; chargeCap = 100; + + defaultAction = AC_SCRY; } public static final String AC_SCRY = "SCRY"; @@ -46,28 +48,32 @@ public class TalismanOfForesight extends Artifact { public void execute( Hero hero, String action ) { super.execute(hero, action); if (action.equals(AC_SCRY)){ - hero.sprite.operate( hero.pos ); - hero.busy(); - Sample.INSTANCE.play( Assets.SND_BEACON ); - charge = 0; - for (int i=0; i < Level.LENGTH; i++) { - int terr = Dungeon.level.map[i]; - if ((Terrain.flags[terr] & Terrain.SECRET) != 0) { + if (!isEquipped(hero)) GLog.i("You need to equip your talisman to do that."); + else if (charge != chargeCap) GLog.i("Your talisman isn't full charged yet."); + else { + hero.sprite.operate(hero.pos); + hero.busy(); + Sample.INSTANCE.play(Assets.SND_BEACON); + charge = 0; + for (int i = 0; i < Level.LENGTH; i++) { - GameScene.updateMap( i ); + int terr = Dungeon.level.map[i]; + if ((Terrain.flags[terr] & Terrain.SECRET) != 0) { - if (Dungeon.visible[i]) { - GameScene.discoverTile( i, terr ); + GameScene.updateMap(i); + + if (Dungeon.visible[i]) { + GameScene.discoverTile(i, terr); + } } } + + GLog.p("The Talisman floods your mind with knowledge about the current floor."); + + Buff.affect(hero, Awareness.class, Awareness.DURATION); + Dungeon.observe(); } - - GLog.p ("The Talisman floods your mind with knowledge about the current floor."); - - Buff.affect(hero, Awareness.class, Awareness.DURATION); - Dungeon.observe(); - } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java index 8a200ed86..7a209f256 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/UnstableSpellbook.java @@ -75,6 +75,8 @@ public class UnstableSpellbook extends Artifact { if (action.equals( AC_READ )) { if (hero.buff( Blindness.class ) != null) GLog.w("You cannot read from the book while blinded."); + else if (!isEquipped( hero )) GLog.i("You need to equip your spellbook to do that."); + else if (charge == 0) GLog.i("Your spellbook is out of energy for now."); else { charge--;