use of mage.cards.Card in project mage by magefree.
the class WandOfDenialEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (controller != null && targetPlayer != null) {
Card card = targetPlayer.getLibrary().getFromTop(game);
if (card != null) {
MageObject sourceObject = game.getObject(source.getSourceId());
controller.lookAtCards(sourceObject != null ? sourceObject.getName() : "", new CardsImpl(card), game);
if (!card.isLand(game) && controller.canPayLifeCost(source) && controller.getLife() >= 2 && controller.chooseUse(Outcome.Neutral, "Pay 2 life to put " + card.getLogName() + " into graveyard?", source, game)) {
controller.loseLife(2, game, source, false);
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
return true;
}
}
return false;
}
use of mage.cards.Card in project mage by magefree.
the class ZursWeirdingReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
boolean paid = false;
Player player = game.getPlayer(event.getTargetId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
return false;
}
Card card = player.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
// Reveals it instead
player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum() + '|' + game.getPhase().getType() + ')', new CardsImpl(card), game);
// Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard
String message = "Pay 2 life to put " + card.getLogName() + " into " + player.getLogName() + " graveyard?";
for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) {
if (playerId.equals(player.getId())) {
continue;
}
Player otherPlayer = game.getPlayer(playerId);
if (otherPlayer == null || !otherPlayer.canPayLifeCost(source) || otherPlayer.getLife() < 2) {
continue;
}
PayLifeCost lifeCost = new PayLifeCost(2);
if (otherPlayer.chooseUse(Outcome.Benefit, message, source, game) && lifeCost.pay(source, game, source, otherPlayer.getId(), true)) {
player.moveCards(card, Zone.GRAVEYARD, source, game);
return true;
}
}
// This is still replacing the draw, so we still return true
player.drawCards(1, source, game, event);
return true;
}
use of mage.cards.Card in project mage by magefree.
the class ZarethSanTheTricksterTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Card card = controller.getHand().get(source.getSourceId(), game);
if (card == null) {
return true;
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
game.getCombat().addAttackingCreature(permanent.getId(), game);
}
return true;
}
use of mage.cards.Card in project mage by magefree.
the class IntetTheDreamerTest method test_SplitCard.
@Test
public void test_SplitCard() {
skipInitShuffling();
// Whenever Intet, the Dreamer deals combat damage to a player, you may pay {2}{U}. If you do, exile
// the top card of your library face down.
// You may play that card without paying its mana cost for as long as Intet remains on the battlefield.
// You may look at that card for as long as it remains exiled.
// 6/6
addCard(Zone.BATTLEFIELD, playerA, "Intet, the Dreamer");
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
//
// Wax {G}
// Target creature gets +2/+2 until end of turn.
// instant, split card
addCard(Zone.LIBRARY, playerA, "Wax // Wane", 1);
// attack and trigger an exile effect
attack(1, playerA, "Intet, the Dreamer");
// pay and exile face down
setChoice(playerA, true);
waitStackResolved(1, PhaseStep.COMBAT_DAMAGE);
// face down for owner looks like a normal card
checkExileCount("after exile", 1, PhaseStep.COMBAT_DAMAGE, playerA, "Wax // Wane", 1);
runCode("after exile", 1, PhaseStep.COMBAT_DAMAGE, playerA, (info, player, game) -> {
Assert.assertEquals("must have 1 card in exile", 1, game.getExile().getAllCards(game).size());
Card card = game.getExile().getAllCards(game).get(0);
Assert.assertTrue("must be face down in exile", card.isFaceDown(game));
});
// free cast and boost intet
castSpell(1, PhaseStep.COMBAT_DAMAGE, playerA, "Wax", "Intet, the Dreamer");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
// boost from Wax
assertPowerToughness(playerA, "Intet, the Dreamer", 6 + 2, 6 + 2);
}
use of mage.cards.Card in project mage by magefree.
the class PutToLibraryTest method testUnexpectedlyAbsent.
// Unexpectedly Absent doesn't work properly, no matter how much you pay for X the card is always returned on top of the library.
@Test
public void testUnexpectedlyAbsent() {
// Flying
// At the beginning of combat on your turn, you may pay {G}{U}. When you do, put a +1/+1 counter on another target creature you control, and that creature gains flying until end of turn.
addCard(Zone.BATTLEFIELD, playerA, "Skyrider Patrol", 1);
// Put target nonland permanent into its owner's library just beneath the top X cards of that library.
// Instant {X}{W}{W}
addCard(Zone.HAND, playerB, "Unexpectedly Absent");
addCard(Zone.BATTLEFIELD, playerB, "Plains", 5);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Unexpectedly Absent", "Skyrider Patrol");
setChoice(playerB, "X=3");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, "Unexpectedly Absent", 1);
assertPermanentCount(playerA, "Skyrider Patrol", 0);
assertLibraryCount(playerA, "Skyrider Patrol", 1);
ArrayList<Card> cardArray = new ArrayList<>(playerA.getLibrary().getCards(currentGame));
Assert.assertTrue("Library has no cards but should have", cardArray.size() > 3);
// get the 4th element
Card fourthCard = cardArray.get(3);
Assert.assertTrue("Fourth card from top should be Skyrider Patrol, but it isn't", fourthCard != null && fourthCard.getName().equals("Skyrider Patrol"));
assertLife(playerA, 20);
assertLife(playerB, 20);
}
Aggregations