Search in sources :

Example 1 with FlavourBuff

use of com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff in project shattered-pixel-dungeon-gdx by 00-Evan.

the class WandOfCorruption method debuffEnemy.

private void debuffEnemy(Mob enemy, HashMap<Class<? extends Buff>, Float> category) {
    // do not consider buffs which are already assigned, or that the enemy is immune to.
    HashMap<Class<? extends Buff>, Float> debuffs = new HashMap<>(category);
    for (Buff existing : enemy.buffs()) {
        if (debuffs.containsKey(existing.getClass())) {
            debuffs.put(existing.getClass(), 0f);
        }
    }
    for (Class<? extends Buff> toAssign : debuffs.keySet()) {
        if (debuffs.get(toAssign) > 0 && enemy.isImmune(toAssign)) {
            debuffs.put(toAssign, 0f);
        }
    }
    // all buffs with a > 0 chance are flavor buffs
    Class<? extends FlavourBuff> debuffCls = (Class<? extends FlavourBuff>) Random.chances(debuffs);
    if (debuffCls != null) {
        Buff.append(enemy, debuffCls, 6 + level() * 3);
    } else {
        // if no debuff can be applied (all are present), then go up one tier
        if (category == MINOR_DEBUFFS)
            debuffEnemy(enemy, MAJOR_DEBUFFS);
        else if (category == MAJOR_DEBUFFS)
            corruptEnemy(enemy);
    }
}
Also used : HashMap(java.util.HashMap) FlavourBuff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff) FlavourBuff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff) Buff(com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)

Aggregations

Buff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff)1 FlavourBuff (com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff)1 HashMap (java.util.HashMap)1