v0.4.0: updated logic for curse wand effect, same as cursing traps

This commit is contained in:
Evan Debenham 2016-06-11 14:25:35 -04:00 committed by Evan Debenham
parent 6b700a96eb
commit 4972092366
2 changed files with 57 additions and 63 deletions

View File

@ -58,6 +58,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportat
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; 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.LightningTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica; import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
@ -315,16 +316,7 @@ public class CursedWand {
//curses! //curses!
case 1: case 1:
KindOfWeapon weapon = user.belongings.weapon; CursingTrap.curse(user);
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") );
wand.wandUsed(); wand.wandUsed();
break; break;

View File

@ -66,62 +66,64 @@ public class CursingTrap extends Trap {
} }
if (Dungeon.hero.pos == pos){ if (Dungeon.hero.pos == pos){
Hero hero = Dungeon.hero; curse(Dungeon.hero);
//items the trap wants to curse because it will create a more negative effect
ArrayList<Item> priorityCurse = new ArrayList<>();
//items the trap can curse if nothing else is available.
ArrayList<Item> 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") );
} }
} }
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<Item> priorityCurse = new ArrayList<>();
//items the trap can curse if nothing else is available.
ArrayList<Item> 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; item.cursed = item.cursedKnown = true;
if (item instanceof Weapon){ if (item instanceof Weapon){