Search in sources :

Example 1 with ConditionalAsThoughEffect

use of mage.abilities.decorator.ConditionalAsThoughEffect 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 ConditionalAsThoughEffect

use of mage.abilities.decorator.ConditionalAsThoughEffect in project mage by magefree.

the class RobberOfTheRichEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (controller == null || damagedPlayer == null) {
        return false;
    }
    Card card = damagedPlayer.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    // move card to exile
    controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    // don't worry about land
    if (card.getSpellAbility() != null) {
        // the exiled card is independent and requires a new ability in case the Robber leaves the battlefield
        // the exiled card can be cast throughout the entire game as long as the controller attacked with a rogue that turn
        Ability copiedAbility = source.copy();
        copiedAbility.newId();
        copiedAbility.setSourceId(card.getId());
        copiedAbility.setControllerId(source.getControllerId());
        PlayFromNotOwnHandZoneTargetEffect playFromExile = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfGame);
        YouMaySpendManaAsAnyColorToCastTargetEffect spendAnyMana = new YouMaySpendManaAsAnyColorToCastTargetEffect(Duration.EndOfGame);
        ConditionalAsThoughEffect castOnlyIfARogueAttackedThisTurn = new ConditionalAsThoughEffect(playFromExile, new RogueAttackedThisTurnCondition(copiedAbility));
        playFromExile.setTargetPointer(new FixedTarget(card, game));
        spendAnyMana.setTargetPointer(new FixedTarget(card, game));
        castOnlyIfARogueAttackedThisTurn.setTargetPointer(new FixedTarget(card, game));
        game.addEffect(castOnlyIfARogueAttackedThisTurn, copiedAbility);
        game.addEffect(spendAnyMana, copiedAbility);
        return true;
    }
    return false;
}
Also used : AttacksTriggeredAbility(mage.abilities.common.AttacksTriggeredAbility) HasteAbility(mage.abilities.keyword.HasteAbility) ReachAbility(mage.abilities.keyword.ReachAbility) ConditionalInterveningIfTriggeredAbility(mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) ConditionalAsThoughEffect(mage.abilities.decorator.ConditionalAsThoughEffect) YouMaySpendManaAsAnyColorToCastTargetEffect(mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect) Card(mage.cards.Card)

Example 3 with ConditionalAsThoughEffect

use of mage.abilities.decorator.ConditionalAsThoughEffect 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

ConditionalAsThoughEffect (mage.abilities.decorator.ConditionalAsThoughEffect)3 Ability (mage.abilities.Ability)2 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 PermanentsOnTheBattlefieldCondition (mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition)2 PlayFromNotOwnHandZoneTargetEffect (mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect)2 Test (org.junit.Test)2 AttacksTriggeredAbility (mage.abilities.common.AttacksTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ConditionalInterveningIfTriggeredAbility (mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility)1 PlayFromNotOwnHandZoneAllEffect (mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneAllEffect)1 YouMaySpendManaAsAnyColorToCastTargetEffect (mage.abilities.effects.common.asthought.YouMaySpendManaAsAnyColorToCastTargetEffect)1 HasteAbility (mage.abilities.keyword.HasteAbility)1 ReachAbility (mage.abilities.keyword.ReachAbility)1 Card (mage.cards.Card)1 Player (mage.players.Player)1 TargetCardInOpponentsGraveyard (mage.target.common.TargetCardInOpponentsGraveyard)1 FixedTarget (mage.target.targetpointer.FixedTarget)1