From 497209236601b3f09277ff5abadb04149e3c50b0 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 11 Jun 2016 14:25:35 -0400 Subject: [PATCH] v0.4.0: updated logic for curse wand effect, same as cursing traps --- .../items/wands/CursedWand.java | 12 +- .../levels/traps/CursingTrap.java | 108 +++++++++--------- 2 files changed, 57 insertions(+), 63 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java index 7de8a382b..65388d71f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/wands/CursedWand.java @@ -58,6 +58,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportat import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.CursingTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.LightningTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; @@ -315,16 +316,7 @@ public class CursedWand { //curses! case 1: - KindOfWeapon weapon = user.belongings.weapon; - Armor armor = user.belongings.armor; - KindofMisc misc1 = user.belongings.misc1; - KindofMisc misc2 = user.belongings.misc2; - if (weapon != null) weapon.cursed = weapon.cursedKnown = true; - if (armor != null) armor.cursed = armor.cursedKnown = true; - if (misc1 != null) misc1.cursed = misc1.cursedKnown = true; - if (misc2 != null) misc2.cursed = misc2.cursedKnown = true; - EquipableItem.equipCursed(user); - GLog.n( Messages.get(CursedWand.class, "cursed") ); + CursingTrap.curse(user); wand.wandUsed(); break; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/CursingTrap.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/CursingTrap.java index 6f9f8af5a..7964846ac 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/CursingTrap.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/CursingTrap.java @@ -66,62 +66,64 @@ public class CursingTrap extends Trap { } if (Dungeon.hero.pos == pos){ - Hero hero = Dungeon.hero; - - //items the trap wants to curse because it will create a more negative effect - ArrayList priorityCurse = new ArrayList<>(); - //items the trap can curse if nothing else is available. - ArrayList canCurse = new ArrayList<>(); - - KindOfWeapon weapon = hero.belongings.weapon; - if (weapon instanceof Weapon && !weapon.cursed){ - if (((Weapon) weapon).enchantment == null) - priorityCurse.add(weapon); - else - canCurse.add(weapon); - } - - Armor armor = hero.belongings.armor; - if (!armor.cursed){ - if (armor.glyph == null) - priorityCurse.add(armor); - else - canCurse.add(armor); - } - - KindofMisc misc1 = hero.belongings.misc1; - if (misc1 instanceof Artifact){ - priorityCurse.add(misc1); - } else if (misc1 instanceof Ring){ - canCurse.add(misc1); - } - - KindofMisc misc2 = hero.belongings.misc2; - if (misc2 instanceof Artifact){ - priorityCurse.add(misc2); - } else if (misc2 instanceof Ring){ - canCurse.add(misc2); - } - - Collections.shuffle(priorityCurse); - Collections.shuffle(canCurse); - - int numCurses = Random.Int(3) == 0 ? 1 : 2; - - for (int i = 0; i < numCurses; i++){ - if (!priorityCurse.isEmpty()){ - curse(priorityCurse.remove(0)); - } else if (!canCurse.isEmpty()){ - curse(canCurse.remove(0)); - } - } - - EquipableItem.equipCursed(hero); - GLog.n( Messages.get(this, "curse") ); + curse(Dungeon.hero); } } - private void curse(Item item){ + public static void curse(Hero hero){ + //items the trap wants to curse because it will create a more negative effect + ArrayList priorityCurse = new ArrayList<>(); + //items the trap can curse if nothing else is available. + ArrayList canCurse = new ArrayList<>(); + + KindOfWeapon weapon = hero.belongings.weapon; + if (weapon instanceof Weapon && !weapon.cursed){ + if (((Weapon) weapon).enchantment == null) + priorityCurse.add(weapon); + else + canCurse.add(weapon); + } + + Armor armor = hero.belongings.armor; + if (!armor.cursed){ + if (armor.glyph == null) + priorityCurse.add(armor); + else + canCurse.add(armor); + } + + KindofMisc misc1 = hero.belongings.misc1; + if (misc1 instanceof Artifact){ + priorityCurse.add(misc1); + } else if (misc1 instanceof Ring){ + canCurse.add(misc1); + } + + KindofMisc misc2 = hero.belongings.misc2; + if (misc2 instanceof Artifact){ + priorityCurse.add(misc2); + } else if (misc2 instanceof Ring){ + canCurse.add(misc2); + } + + Collections.shuffle(priorityCurse); + Collections.shuffle(canCurse); + + int numCurses = Random.Int(3) == 0 ? 1 : 2; + + for (int i = 0; i < numCurses; i++){ + if (!priorityCurse.isEmpty()){ + curse(priorityCurse.remove(0)); + } else if (!canCurse.isEmpty()){ + curse(canCurse.remove(0)); + } + } + + EquipableItem.equipCursed(hero); + GLog.n( Messages.get(CursingTrap.class, "curse") ); + } + + private static void curse(Item item){ item.cursed = item.cursedKnown = true; if (item instanceof Weapon){