Search in sources :

Example 1 with AttacksIfAbleAllEffect

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;
}
Also used : RequirementEffect(mage.abilities.effects.RequirementEffect) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)

Example 2 with AttacksIfAbleAllEffect

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;
}
Also used : RequirementEffect(mage.abilities.effects.RequirementEffect) Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)

Example 3 with AttacksIfAbleAllEffect

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;
}
Also used : RequirementEffect(mage.abilities.effects.RequirementEffect) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)

Example 4 with AttacksIfAbleAllEffect

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();
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) AttackedThisTurnWatcher(mage.watchers.common.AttackedThisTurnWatcher) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect) Test(org.junit.Test)

Example 5 with AttacksIfAbleAllEffect

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;
}
Also used : RequirementEffect(mage.abilities.effects.RequirementEffect) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)

Aggregations

AttacksIfAbleAllEffect (mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)5 RequirementEffect (mage.abilities.effects.RequirementEffect)4 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)4 Player (mage.players.Player)4 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)3 TargetPlayer (mage.target.TargetPlayer)2 MageObject (mage.MageObject)1 Ability (mage.abilities.Ability)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 Choice (mage.choices.Choice)1 ChoiceCreatureType (mage.choices.ChoiceCreatureType)1 AttackedThisTurnWatcher (mage.watchers.common.AttackedThisTurnWatcher)1 Test (org.junit.Test)1