Search in sources :

Example 26 with TargetCard

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;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 27 with TargetCard

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;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 28 with TargetCard

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 29 with TargetCard

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;
}
Also used : Player(mage.players.Player) FilterNonlandCard(mage.filter.common.FilterNonlandCard) Permanent(mage.game.permanent.Permanent) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard)

Example 30 with TargetCard

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;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Aggregations

TargetCard (mage.target.TargetCard)309 Player (mage.players.Player)297 FilterCard (mage.filter.FilterCard)177 Card (mage.cards.Card)130 CardsImpl (mage.cards.CardsImpl)96 UUID (java.util.UUID)83 Cards (mage.cards.Cards)81 MageObject (mage.MageObject)80 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)52 Permanent (mage.game.permanent.Permanent)49 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)30 ApprovingObject (mage.ApprovingObject)26 TargetPlayer (mage.target.TargetPlayer)25 FilterCreatureCard (mage.filter.common.FilterCreatureCard)22 TargetOpponent (mage.target.common.TargetOpponent)22 TargetCardInHand (mage.target.common.TargetCardInHand)21 Target (mage.target.Target)19 FilterNonlandCard (mage.filter.common.FilterNonlandCard)18 FixedTarget (mage.target.targetpointer.FixedTarget)18 ArrayList (java.util.ArrayList)16