Search in sources :

Example 11 with TargetCard

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

the class KaaliaZenithSeekerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 6));
    Cards toHand = new CardsImpl();
    for (CreatureFinder creatureFinder : CreatureFinder.values()) {
        TargetCard targetCard = creatureFinder.getTarget();
        if (player.choose(outcome, cards, targetCard, game)) {
            toHand.addAll(targetCard.getTargets());
        }
    }
    cards.removeAll(toHand);
    player.revealCards(source, toHand, game);
    player.moveCards(toHand, Zone.HAND, source, game);
    player.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 12 with TargetCard

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

the class LostHoursEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (targetPlayer != null && controller != null) {
        targetPlayer.revealCards(source, targetPlayer.getHand(), game);
        if (targetPlayer.getHand().size() > 0) {
            TargetCard target = new TargetCard(Zone.HAND, new FilterCard(StaticFilters.FILTER_CARD_A_NON_LAND));
            if (controller.choose(Outcome.Discard, targetPlayer.getHand(), target, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    targetPlayer.putCardOnTopXOfLibrary(card, game, source, 3, true);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 13 with TargetCard

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

the class LordOfTheVoidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (player == null || controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7));
    controller.moveCards(cards, Zone.EXILED, source, game);
    if (!cards.getCards(StaticFilters.FILTER_CARD_CREATURE, game).isEmpty()) {
        TargetCard target = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_CREATURE);
        if (controller.chooseTarget(outcome, cards, target, source, game)) {
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null);
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 14 with TargetCard

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

the class MemoryLeakEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (controller == null || opponent == null) {
        return false;
    }
    opponent.revealCards(source, opponent.getHand(), game);
    TargetCard target;
    Cards cards;
    if (controller.chooseUse(outcome, "Exile a card from hand or graveyard?", null, "Hand", "Graveyard", source, game)) {
        FilterCard filter = new FilterNonlandCard("nonland card in " + opponent.getName() + "'s hand");
        target = new TargetCard(Zone.HAND, filter);
        target.setNotTarget(true);
        cards = opponent.getHand();
    } else {
        FilterCard filter = new FilterNonlandCard("nonland card in " + opponent.getName() + "'s graveyard");
        target = new TargetCard(Zone.GRAVEYARD, filter);
        target.setNotTarget(true);
        cards = opponent.getGraveyard();
    }
    if (controller.choose(outcome, cards, target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.moveCards(card, Zone.EXILED, source, game);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) FilterCard(mage.filter.FilterCard) FilterNonlandCard(mage.filter.common.FilterNonlandCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 15 with TargetCard

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

the class MurmursFromBeyondEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject != null && controller != null) {
        Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3));
        if (!cards.isEmpty()) {
            controller.revealCards(staticText, cards, game);
            Card cardToGraveyard;
            if (cards.size() == 1) {
                cardToGraveyard = cards.getRandom(game);
            } else {
                Player opponent;
                Set<UUID> opponents = game.getOpponents(controller.getId());
                if (opponents.size() == 1) {
                    opponent = game.getPlayer(opponents.iterator().next());
                } else {
                    Target target = new TargetOpponent(true);
                    controller.chooseTarget(Outcome.Detriment, target, source, game);
                    opponent = game.getPlayer(target.getFirstTarget());
                }
                TargetCard target = new TargetCard(1, Zone.LIBRARY, new FilterCard());
                opponent.chooseTarget(outcome, cards, target, source, game);
                cardToGraveyard = game.getCard(target.getFirstTarget());
            }
            if (cardToGraveyard != null) {
                controller.moveCards(cardToGraveyard, Zone.GRAVEYARD, source, game);
                cards.remove(cardToGraveyard);
            }
            controller.moveCards(cards, Zone.HAND, source, game);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Target(mage.target.Target) TargetOpponent(mage.target.common.TargetOpponent) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

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