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;
}
Aggregations