Search in sources :

Example 71 with TargetCard

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

the class AugurOfBolasEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        Cards topCards = new CardsImpl();
        topCards.addAll(controller.getLibrary().getTopCards(game, 3));
        if (!topCards.isEmpty()) {
            controller.lookAtCards(sourceObject.getIdName(), topCards, game);
            int number = topCards.count(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game);
            if (number > 0) {
                if (controller.chooseUse(outcome, "Reveal an instant or sorcery card from the looked at cards and put it into your hand?", source, game)) {
                    Card card = null;
                    if (number == 1) {
                        Set<Card> cards = topCards.getCards(new FilterInstantOrSorceryCard(), source.getSourceId(), source.getControllerId(), game);
                        if (!cards.isEmpty()) {
                            card = cards.iterator().next();
                        }
                    } else {
                        TargetCard target = new TargetCard(Zone.LIBRARY, new FilterInstantOrSorceryCard());
                        controller.chooseTarget(outcome, topCards, target, source, game);
                        card = topCards.get(target.getFirstTarget(), game);
                    }
                    if (card != null) {
                        controller.moveCards(card, Zone.HAND, source, game);
                        controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
                        topCards.remove(card);
                    }
                }
            }
            controller.putCardsOnBottomOfLibrary(topCards, game, source, true);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard)

Example 72 with TargetCard

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

the class AtrisOracleOfHalfTruthsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || targetOpponent == null || sourceObject == null) {
        return false;
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 3));
    TargetCard target = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
    targetOpponent.choose(outcome, cards, target, game);
    Cards faceDownPile = new CardsImpl(target.getTargets());
    cards.removeAll(target.getTargets());
    controller.revealCards(sourceObject.getIdName() + " - cards in face-up pile", cards, game);
    game.informPlayers(targetOpponent.getLogName() + " puts " + faceDownPile.size() + " card(s) into the face-down pile");
    if (controller.chooseUse(outcome, "Choose a pile to put in your hand.", null, "Face-down", "Face-up", source, game)) {
        controller.moveCards(faceDownPile, Zone.HAND, source, game);
        controller.moveCards(cards, Zone.GRAVEYARD, source, game);
    } else {
        controller.moveCards(faceDownPile, Zone.GRAVEYARD, source, game);
        controller.moveCards(cards, Zone.HAND, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 73 with TargetCard

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

the class AshnodsCylixEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
    player.lookAtCards(source, null, cards, game);
    TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on top of your library"));
    if (player.choose(Outcome.Benefit, cards, target, game)) {
        Card card = cards.get(target.getFirstTarget(), game);
        if (card != null) {
            cards.remove(card);
            game.informPlayers(source.getSourceObject(game).getIdName() + ": " + player.getLogName() + " puts a card back on top of their library");
        }
    }
    player.moveCards(cards, Zone.EXILED, source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) 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 74 with TargetCard

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

the class SearchForBlexEffect method actionWithSelectedCards.

@Override
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        TargetCard target = new TargetCard(0, 5, Zone.LIBRARY, filter);
        if (player.choose(outcome, cards, target, game)) {
            Cards pickedCards = new CardsImpl(target.getTargets());
            cards.removeAll(pickedCards);
            player.moveCards(pickedCards, Zone.HAND, source, game);
            player.loseLife(pickedCards.size() * 3, game, source, false);
        }
    }
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 75 with TargetCard

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

the class BountyOfSkemfarEffect 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));
    player.revealCards(source, cards, game);
    TargetCard target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_LAND);
    player.choose(outcome, cards, target, game);
    Card land = cards.get(target.getFirstTarget(), game);
    if (land != null) {
        player.moveCards(land, Zone.BATTLEFIELD, source, game, true, false, false, null);
    }
    cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.LIBRARY);
    target = new TargetCardInLibrary(0, 1, filter);
    player.choose(outcome, cards, target, game);
    Card elf = cards.get(target.getFirstTarget(), game);
    if (elf != null) {
        player.moveCards(elf, Zone.HAND, source, game);
    }
    cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.LIBRARY);
    player.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) 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