use of mage.target.TargetCard in project mage by magefree.
the class HideawayLookAtFaceDownCardEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
// LKI is required for this ruling
/*
If Watcher for Tomorrow leaves the battlefield before its
triggered ability from hideaway resolves, its leaves-the-battlefield
ability resolves and does nothing. Then its enters-the-battlefield
ability resolves and you exile a card with no way to return it to your hand.
*/
Permanent hideawaySource = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (hideawaySource == null || controller == null) {
return false;
}
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
TargetCard target1 = new TargetCard(Zone.LIBRARY, filter1);
target1.setNotTarget(true);
if (controller.choose(Outcome.Detriment, cards, target1, game)) {
Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
controller.moveCardToExileWithInfo(card, exileId, "Hideaway (" + hideawaySource.getIdName() + ')', source, game, Zone.LIBRARY, false);
card.setFaceDown(true, game);
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class AcolyteOfAfflictionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.moveCards(player.getLibrary().getTopCards(game, 2), Zone.GRAVEYARD, source, game);
TargetCard target = new TargetCardInYourGraveyard(0, 1, filter, true);
if (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
return true;
}
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return true;
}
player.moveCards(card, Zone.HAND, source, game);
return true;
}
use of mage.target.TargetCard in project mage by magefree.
the class AminatousAuguryCastFromExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
// move cards from library to exile
controller.moveCardsToExile(controller.getLibrary().getTopCards(game, 8), source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null));
ExileZone auguryExileZone = game.getExile().getExileZone(source.getSourceId());
if (auguryExileZone == null) {
return true;
}
Cards cardsToCast = new CardsImpl();
cardsToCast.addAll(auguryExileZone.getCards(game));
// put a land card from among them onto the battlefield
TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_LAND_A);
if (cardsToCast.count(StaticFilters.FILTER_CARD_LAND, game) > 0) {
if (controller.chooseUse(Outcome.PutLandInPlay, "Put a land from among the exiled cards into play?", source, game)) {
if (controller.choose(Outcome.PutLandInPlay, cardsToCast, target, game)) {
Card card = cardsToCast.get(target.getFirstTarget(), game);
if (card != null) {
cardsToCast.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
}
}
}
}
for (Card card : cardsToCast.getCards(StaticFilters.FILTER_CARD_NON_LAND, game)) {
AminatousAuguryCastFromExileEffect effect = new AminatousAuguryCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
}
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class AlhammarretHighArbiterCantCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards revealedCards = new CardsImpl();
for (UUID playerId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null) {
Cards cards = new CardsImpl(opponent.getHand());
opponent.revealCards(opponent.getName() + "'s hand", cards, game);
revealedCards.addAll(cards);
}
}
TargetCard target = new TargetCard(Zone.HAND, new FilterNonlandCard("nonland card from an opponents hand"));
controller.chooseTarget(Outcome.Benefit, revealedCards, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
game.informPlayers("The choosen card name is [" + GameLog.getColoredObjectName(card) + ']');
Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId());
if (sourcePermanent == null) {
sourcePermanent = game.getPermanentEntering(source.getSourceId());
}
if (sourcePermanent != null) {
sourcePermanent.addInfo("chosen card name", CardUtil.addToolTipMarkTags("Chosen card name: " + card.getName()), game);
}
game.addEffect(new AlhammarretHighArbiterCantCastEffect(card.getName()), source);
}
return true;
}
return false;
}
use of mage.target.TargetCard in project mage by magefree.
the class AmassTheComponentsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.drawCards(3, source, game);
if (!player.getHand().isEmpty()) {
FilterCard filter = new FilterCard("card from your hand to put on the bottom of your library");
TargetCard target = new TargetCard(Zone.HAND, filter);
if (player.choose(Outcome.Detriment, player.getHand(), target, game)) {
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
return player.putCardsOnBottomOfLibrary(card, game, source, true);
}
}
}
return true;
}
Aggregations