Search in sources :

Example 31 with TargetCard

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

the class BagOfDevouringEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int result = player.rollDice(Outcome.Benefit, source, game, 10);
    TargetCard target = new TargetCardInExile(0, result, StaticFilters.FILTER_CARD, CardUtil.getExileZoneId(game, source));
    target.setNotTarget(true);
    player.choose(outcome, target, source.getSourceId(), game);
    player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCardInExile(mage.target.common.TargetCardInExile) TargetCard(mage.target.TargetCard) CardsImpl(mage.cards.CardsImpl)

Example 32 with TargetCard

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

the class CavalierOfThornsEffect 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, 5));
    if (cards.isEmpty()) {
        return true;
    }
    controller.revealCards(source, cards, game);
    TargetCard target = new TargetCard(1, 1, Zone.LIBRARY, filter);
    if (cards.getCards(game).stream().anyMatch(card1 -> card1.isLand(game)) && controller.choose(Outcome.PutCardInPlay, cards, target, game)) {
        Card card = cards.get(target.getFirstTarget(), game);
        if (card != null) {
            cards.remove(card);
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
    }
    controller.moveCards(cards, Zone.GRAVEYARD, source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Zone(mage.constants.Zone) PutOnLibraryTargetEffect(mage.abilities.effects.common.PutOnLibraryTargetEffect) mage.cards(mage.cards) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) DiesSourceTriggeredAbility(mage.abilities.common.DiesSourceTriggeredAbility) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) ExileSourceFromGraveCost(mage.abilities.costs.common.ExileSourceFromGraveCost) UUID(java.util.UUID) MageInt(mage.MageInt) ReachAbility(mage.abilities.keyword.ReachAbility) SubType(mage.constants.SubType) Player(mage.players.Player) FilterLandCard(mage.filter.common.FilterLandCard) Game(mage.game.Game) TargetCard(mage.target.TargetCard) CardType(mage.constants.CardType) AnotherPredicate(mage.filter.predicate.mageobject.AnotherPredicate) Ability(mage.abilities.Ability) Player(mage.players.Player) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) FilterLandCard(mage.filter.common.FilterLandCard) TargetCard(mage.target.TargetCard)

Example 33 with TargetCard

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

the class CommuneWithTheGodsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
        if (!cards.isEmpty()) {
            FilterCard filterPutInHand = new FilterCard("creature or enchantment card to put in hand");
            filterPutInHand.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.ENCHANTMENT.getPredicate()));
            controller.revealCards(source, cards, game);
            if (cards.count(filterPutInHand, source.getSourceId(), source.getControllerId(), game) > 0) {
                TargetCard target = new TargetCard(0, 1, Zone.LIBRARY, filterPutInHand);
                if (controller.choose(Outcome.DrawCard, cards, target, game)) {
                    Card card = game.getCard(target.getFirstTarget());
                    if (card != null) {
                        cards.remove(card);
                        controller.moveCards(card, Zone.HAND, source, game);
                    }
                }
            }
            controller.moveCards(cards, Zone.GRAVEYARD, source, game);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

Example 34 with TargetCard

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

the class DakkonShadowSlayerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    boolean inGrave = player.getGraveyard().count(StaticFilters.FILTER_CARD_ARTIFACT, game) > 0;
    if (!inGrave && player.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game) < 1) {
        return false;
    }
    TargetCard target;
    if (!inGrave || player.chooseUse(outcome, "Choose a card in your hand or your graveyard?", null, "Hand", "Graveyard", source, game)) {
        target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_ARTIFACT);
        player.choose(outcome, player.getHand(), target, game);
    } else {
        target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_ARTIFACT);
        player.choose(outcome, player.getGraveyard(), target, game);
    }
    Card card = game.getCard(target.getFirstTarget());
    return card != null && player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCard(mage.target.TargetCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 35 with TargetCard

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

the class GiftOfTheGargantuanTarget 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, 4));
    TargetCard target = new GiftOfTheGargantuanTarget();
    player.choose(outcome, cards, target, game);
    Cards toHand = new CardsImpl();
    toHand.addAll(target.getTargets());
    player.revealCards(source, toHand, game);
    player.moveCards(toHand, Zone.HAND, source, game);
    cards.removeAll(toHand);
    player.putCardsOnBottomOfLibrary(cards, game, source, true);
    return true;
}
Also used : Player(mage.players.Player) 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