Search in sources :

Example 1 with PreventionEffect

use of mage.abilities.effects.PreventionEffect in project mage by magefree.

the class FeintEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (controller != null && creature != null) {
        for (CombatGroup combatGroup : game.getCombat().getGroups()) {
            if (combatGroup.getAttackers().contains(creature.getId())) {
                for (UUID blockerId : combatGroup.getBlockers()) {
                    Permanent blocker = game.getPermanent(blockerId);
                    if (blocker != null) {
                        blocker.tap(source, game);
                        PreventionEffect effect = new PreventDamageByTargetEffect(Duration.EndOfTurn, true);
                        effect.setTargetPointer(new FixedTarget(blocker.getId(), game));
                        game.addEffect(effect, source);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) PreventDamageByTargetEffect(mage.abilities.effects.common.PreventDamageByTargetEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) CombatGroup(mage.game.combat.CombatGroup) PreventionEffect(mage.abilities.effects.PreventionEffect)

Aggregations

UUID (java.util.UUID)1 PreventionEffect (mage.abilities.effects.PreventionEffect)1 PreventDamageByTargetEffect (mage.abilities.effects.common.PreventDamageByTargetEffect)1 CombatGroup (mage.game.combat.CombatGroup)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 FixedTarget (mage.target.targetpointer.FixedTarget)1