use of com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CursingTrap method curse.
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 && !(weapon instanceof Boomerang)) {
if (((Weapon) weapon).enchantment == null)
priorityCurse.add(weapon);
else
canCurse.add(weapon);
}
Armor armor = hero.belongings.armor;
if (armor != null && !armor.cursed) {
if (armor.glyph == null)
priorityCurse.add(armor);
else
canCurse.add(armor);
}
KindofMisc misc1 = hero.belongings.misc1;
if (misc1 != null) {
canCurse.add(misc1);
}
KindofMisc misc2 = hero.belongings.misc2;
if (misc2 != null) {
canCurse.add(misc2);
}
Collections.shuffle(priorityCurse);
Collections.shuffle(canCurse);
int numCurses = Random.Int(2) == 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"));
}
Aggregations