Search in sources :

Example 1 with PermanentsOnTheBattlefieldCondition

use of mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition in project mage by magefree.

the class ConditionalAsThoughTest method test_PlayFromNotOwnHandZoneTargetEffect.

@Test
public void test_PlayFromNotOwnHandZoneTargetEffect() {
    Ability ability = new SimpleActivatedAbility(Zone.ALL, new ConditionalAsThoughEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.GRAVEYARD, TargetController.ANY, Duration.EndOfTurn), new PermanentsOnTheBattlefieldCondition(StaticFilters.FILTER_PERMANENT_CREATURE, ComparisonType.MORE_THAN, 0)).setText("allow target cast"), new ManaCostsImpl("{R}"));
    ability.addTarget(new TargetCardInOpponentsGraveyard(StaticFilters.FILTER_CARD));
    addCustomCardWithAbility("play any opponent hand", playerA, ability);
    addCard(Zone.HAND, playerA, "Grizzly Bears");
    addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
    addCard(Zone.GRAVEYARD, playerB, "Lightning Bolt");
    addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
    addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
    // can't play grave before
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", true);
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
    // activate target effect
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{R}: Allow");
    addTarget(playerA, "Lightning Bolt");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    // can't play grave after but without good condition
    checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", true);
    checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
    checkPlayableAbility("after bad", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
    // make good condition - now we can play opponent's grave
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", false);
    checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
    checkPlayableAbility("after good", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", true);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
    execute();
    assertAllCommandsUsed();
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) ConditionalAsThoughEffect(mage.abilities.decorator.ConditionalAsThoughEffect) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) TargetCardInOpponentsGraveyard(mage.target.common.TargetCardInOpponentsGraveyard) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Test(org.junit.Test)

Example 2 with PermanentsOnTheBattlefieldCondition

use of mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition in project mage by magefree.

the class SanctuaryInterveningIfTriggeredAbility method makeAndCondition.

private static Condition makeAndCondition(ObjectColor color1, ObjectColor color2) {
    FilterPermanent filter1 = new FilterPermanent();
    filter1.add(new ColorPredicate(color1));
    Condition condition1 = new PermanentsOnTheBattlefieldCondition(filter1);
    FilterPermanent filter2 = new FilterPermanent();
    filter2.add(new ColorPredicate(color2));
    Condition condition2 = new PermanentsOnTheBattlefieldCondition(filter2);
    return new CompoundCondition(condition1, condition2);
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) CompoundCondition(mage.abilities.condition.CompoundCondition) Condition(mage.abilities.condition.Condition) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) InvertCondition(mage.abilities.condition.InvertCondition) FilterPermanent(mage.filter.FilterPermanent) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) CompoundCondition(mage.abilities.condition.CompoundCondition)

Example 3 with PermanentsOnTheBattlefieldCondition

use of mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition in project mage by magefree.

the class SanctuaryInterveningIfTriggeredAbility method makeOrCondition.

private static Condition makeOrCondition(ObjectColor color1, ObjectColor color2) {
    FilterPermanent filter = new FilterPermanent();
    filter.add(Predicates.or(new ColorPredicate(color1), new ColorPredicate(color2)));
    return new PermanentsOnTheBattlefieldCondition(filter);
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) FilterPermanent(mage.filter.FilterPermanent) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition)

Example 4 with PermanentsOnTheBattlefieldCondition

use of mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition in project mage by magefree.

the class RoarOfJukaiEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (new PermanentsOnTheBattlefieldCondition(filter).apply(game, source)) {
            for (Permanent permanent : game.getBattlefield().getActivePermanents(filterBlocked, source.getControllerId(), source.getSourceId(), game)) {
                ContinuousEffect effect = new BoostTargetEffect(2, 2, Duration.EndOfTurn);
                effect.setTargetPointer(new FixedTarget(permanent, game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 5 with PermanentsOnTheBattlefieldCondition

use of mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition in project mage by magefree.

the class ConditionalAsThoughTest method test_PlayFromNotOwnHandZoneAllEffect.

@Test
public void test_PlayFromNotOwnHandZoneAllEffect() {
    removeAllCardsFromLibrary(playerA);
    removeAllCardsFromLibrary(playerB);
    addCustomCardWithAbility("play any library on any creature", playerA, new SimpleStaticAbility(Zone.ALL, new ConditionalAsThoughEffect(new PlayFromNotOwnHandZoneAllEffect(StaticFilters.FILTER_CARD, Zone.LIBRARY, false, TargetController.ANY, Duration.EndOfTurn), new PermanentsOnTheBattlefieldCondition(StaticFilters.FILTER_PERMANENT_CREATURE, ComparisonType.MORE_THAN, 0))));
    addCard(Zone.HAND, playerA, "Grizzly Bears");
    addCard(Zone.LIBRARY, playerA, "Silvercoat Lion");
    addCard(Zone.LIBRARY, playerB, "Lightning Bolt");
    addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
    addCard(Zone.BATTLEFIELD, playerA, "Forest", 5);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
    // can't play lib's card before good condition
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", true);
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", false);
    checkPlayableAbility("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", false);
    // make good condition - now we can play any lib's card
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears");
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    checkPlayableAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", false);
    checkPlayableAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Silvercoat Lion", true);
    checkPlayableAbility("after", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Lightning Bolt", true);
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
    execute();
    assertAllCommandsUsed();
}
Also used : ConditionalAsThoughEffect(mage.abilities.decorator.ConditionalAsThoughEffect) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) PermanentsOnTheBattlefieldCondition(mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition) PlayFromNotOwnHandZoneAllEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneAllEffect) Test(org.junit.Test)

Aggregations

PermanentsOnTheBattlefieldCondition (mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition)5 FilterPermanent (mage.filter.FilterPermanent)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 ConditionalAsThoughEffect (mage.abilities.decorator.ConditionalAsThoughEffect)2 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)2 Test (org.junit.Test)2 Ability (mage.abilities.Ability)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 CompoundCondition (mage.abilities.condition.CompoundCondition)1 Condition (mage.abilities.condition.Condition)1 InvertCondition (mage.abilities.condition.InvertCondition)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 PlayFromNotOwnHandZoneAllEffect (mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneAllEffect)1 PlayFromNotOwnHandZoneTargetEffect (mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect)1 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetCardInOpponentsGraveyard (mage.target.common.TargetCardInOpponentsGraveyard)1