use of mage.abilities.effects.common.combat.AttacksIfAbleAllEffect in project mage by magefree.
the class InstigatorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(player.getId()));
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.combat.AttacksIfAbleAllEffect in project mage by magefree.
the class WalkingDesecrationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null) {
if (sourceObject != null) {
Choice typeChoice = new ChoiceCreatureType(sourceObject);
if (player.choose(outcome, typeChoice, game)) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
}
}
return false;
}
use of mage.abilities.effects.common.combat.AttacksIfAbleAllEffect in project mage by magefree.
the class InciteWarMustAttackEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(player.getId()));
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.abilities.effects.common.combat.AttacksIfAbleAllEffect in project mage by magefree.
the class WallOfDustNextTurnTest method test_SingleOpponentMustAttack.
@Test
public void test_SingleOpponentMustAttack() {
// Whenever Wall of Dust blocks a creature, that creature can't attack during its controller's next turn.
addCard(Zone.BATTLEFIELD, playerA, "Wall of Dust");
// 2/2
addCard(Zone.BATTLEFIELD, playerB, "Balduvian Bears", 1);
// 2/2
addCard(Zone.BATTLEFIELD, playerB, "Ashcoat Bear", 1);
//
Ability ability = new SimpleStaticAbility(new AttacksIfAbleAllEffect(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, Duration.EndOfGame));
ability.addWatcher(new AttackedThisTurnWatcher());
addCustomCardWithAbility("all attacks", playerA, ability);
// 1 - nothing
checkPermanentCount("turn 1", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
checkPermanentCount("turn 1", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
checkLife("turn 1", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, 20);
// 2 - auto-attack B -> A, 1 attacked, 1 blocked (by wall)
block(2, playerA, "Wall of Dust", "Balduvian Bears");
checkPermanentCount("turn 2", 2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
checkPermanentCount("turn 2", 2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
checkLife("turn 2", 2, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2);
// 3 - nothing
checkPermanentCount("turn 3", 3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
checkPermanentCount("turn 3", 3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
checkLife("turn 3", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2);
// 4 - auto-attack, B -> A, 1 attacked, 1 can't attacked (by wall's abilitiy during next turn)
checkPermanentCount("turn 4", 4, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
checkPermanentCount("turn 4", 4, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
checkLife("turn 4", 4, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2 * 2);
// 5 - nothing
checkPermanentCount("turn 5", 5, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
checkPermanentCount("turn 5", 5, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
checkLife("turn 5", 5, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2 * 2);
// 6 - auto-attack, B -> A, 2 attacked
checkPermanentCount("turn 6", 6, PhaseStep.POSTCOMBAT_MAIN, playerB, "Balduvian Bears", 1);
checkPermanentCount("turn 6", 6, PhaseStep.POSTCOMBAT_MAIN, playerB, "Ashcoat Bear", 1);
checkLife("turn 6", 6, PhaseStep.POSTCOMBAT_MAIN, playerA, 20 - 2 * 2 - 2 * 2);
setStopAt(6, PhaseStep.END_TURN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
}
use of mage.abilities.effects.common.combat.AttacksIfAbleAllEffect in project mage by magefree.
the class ImaginaryThreatsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(player.getId()));
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
return false;
}
Aggregations