Search in sources :

Example 21 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class PsychoticEpisodeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player != null && controller != null && sourceObject != null) {
        TargetCard targetCard = new TargetCard(Zone.ALL, new FilterCard());
        targetCard.setRequired(true);
        Cards options = player.getHand().copy();
        Card topdeck = player.getLibrary().getFromTop(game);
        options.add(topdeck);
        controller.lookAtCards("Top of Library (Psychotic Episode)", topdeck, game);
        if (controller.choose(Outcome.Discard, options, targetCard, game)) {
            Card card = game.getCard(targetCard.getFirstTarget());
            if (card != null) {
                CardsImpl cards = new CardsImpl();
                cards.add(card);
                player.revealCards(sourceObject.getIdName(), cards, game);
                player.putCardsOnBottomOfLibrary(cards, game, source, true);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 22 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class DevelopmentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseUse(Outcome.Benefit, staticText + "?", source, game)) {
            Cards cards = controller.getSideboard();
            if (cards.isEmpty()) {
                game.informPlayer(controller, "You have no cards outside the game.");
                return true;
            }
            TargetCard target = new TargetCard(0, 4, Zone.OUTSIDE, new FilterCard("cards you own from outside the game"));
            target.setNotTarget(true);
            if (controller.choose(Outcome.Benefit, controller.getSideboard(), target, game)) {
                controller.shuffleCardsToLibrary(new CardsImpl(target.getTargets()), game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCard(mage.target.TargetCard)

Example 23 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class SummoningTrapEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
    if (!cards.isEmpty()) {
        TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put on the battlefield"));
        if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                cards.remove(card);
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
        if (!cards.isEmpty()) {
            controller.putCardsOnBottomOfLibrary(cards, game, source, true);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard)

Example 24 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class ExileAllCardsFromAllGraveyards method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject Valki = game.getObject(source.getSourceId());
    Set<Card> cardsToExile = new LinkedHashSet<>();
    if (controller != null && Valki != null) {
        UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + Valki.getZoneChangeCounter(game), game);
        for (UUID opponentId : game.getOpponents(controller.getId())) {
            Player opponent = game.getPlayer(opponentId);
            if (opponent != null) {
                opponent.revealCards(source, opponent.getHand(), game);
                TargetCard targetToExile = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_CREATURE);
                targetToExile.withChooseHint("card to exile");
                targetToExile.setNotTarget(true);
                if (controller.choose(Outcome.Exile, opponent.getHand(), targetToExile, game)) {
                    Card targetedCardToExile = game.getCard(targetToExile.getFirstTarget());
                    if (targetedCardToExile != null && game.getState().getZone(source.getSourceId()) == Zone.BATTLEFIELD) {
                        cardsToExile.add(targetedCardToExile);
                    }
                }
            }
        }
        // exile all cards at one time
        controller.moveCardsToExile(cardsToExile, source, game, true, exileId, Valki.getName());
        game.addDelayedTriggeredAbility(new ValkiGodOfLiesReturnExiledCardAbility(), source);
        return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) ModalDoubleFacesCard(mage.cards.ModalDoubleFacesCard)

Example 25 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class ExploreTheVastlandsTarget method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 5));
        TargetCard target = new ExploreTheVastlandsTarget();
        player.choose(outcome, cards, target, game);
        Cards toHand = new CardsImpl(target.getTargets());
        cards.removeIf(target.getTargets()::contains);
        player.revealCards(source, toHand, game);
        player.moveCards(toHand, Zone.HAND, source, game);
        player.putCardsOnBottomOfLibrary(cards, game, source, false);
    }
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            player.gainLife(3, game, source);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) UUID(java.util.UUID)

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