Search in sources :

Example 1 with Boomerang

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"));
}
Also used : EquipableItem(com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem) Item(com.shatteredpixel.shatteredpixeldungeon.items.Item) Armor(com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor) KindofMisc(com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc) ArrayList(java.util.ArrayList) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon) Boomerang(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang) KindOfWeapon(com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon) Weapon(com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon)

Aggregations

EquipableItem (com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem)1 Item (com.shatteredpixel.shatteredpixeldungeon.items.Item)1 KindOfWeapon (com.shatteredpixel.shatteredpixeldungeon.items.KindOfWeapon)1 KindofMisc (com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc)1 Armor (com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor)1 Weapon (com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon)1 Boomerang (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang)1 ArrayList (java.util.ArrayList)1