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