Search in sources :

Example 91 with Card

use of mage.cards.Card in project mage by magefree.

the class ExileSourceFromGraveCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        Card card = game.getCard(source.getSourceId());
        if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
            controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.GRAVEYARD, true);
            // 117.11. The actions performed when paying a cost may be modified by effects.
            // Even if they are, meaning the actions that are performed don't match the actions
            // that are called for, the cost has still been paid.
            // so return state here is not important because the user indended to exile the target anyway
            paid = true;
        }
    }
    return paid;
}
Also used : Player(mage.players.Player) Card(mage.cards.Card)

Example 92 with Card

use of mage.cards.Card in project mage by magefree.

the class ExileTopCreatureCardOfGraveyardCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        Card topCard = null;
        for (Card card : controller.getGraveyard().getCards(game)) {
            if (card.isCreature(game)) {
                topCard = card;
            }
        }
        if (topCard != null) {
            controller.moveCardToExileWithInfo(topCard, null, "", source, game, Zone.GRAVEYARD, true);
            paid = true;
        }
    }
    return paid;
}
Also used : Player(mage.players.Player) Card(mage.cards.Card)

Example 93 with Card

use of mage.cards.Card in project mage by magefree.

the class RevealSourceFromYourHandCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    paid = false;
    Player player = game.getPlayer(controllerId);
    if (player != null) {
        Card card = player.getHand().get(ability.getSourceId(), game);
        if (card != null) {
            Cards cards = new CardsImpl(card);
            paid = true;
            player.revealCards("Reveal card cost", cards, game);
        }
    }
    return paid;
}
Also used : Player(mage.players.Player) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 94 with Card

use of mage.cards.Card in project mage by magefree.

the class ExileFromGraveCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
            for (UUID targetId : targets.get(0).getTargets()) {
                Card card = game.getCard(targetId);
                if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) {
                    return false;
                }
                exiledCards.add(card);
            }
            Cards cardsToExile = new CardsImpl();
            cardsToExile.addAll(exiledCards);
            controller.moveCardsToExile(cardsToExile.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
            if (setTargetPointer) {
                source.getEffects().setTargetPointer(new FixedTargets(cardsToExile, game));
            }
            paid = true;
        }
    }
    return paid;
}
Also used : Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 95 with Card

use of mage.cards.Card in project mage by magefree.

the class ReturnToHandFromGraveyardCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        if (targets.choose(Outcome.ReturnToHand, controllerId, source.getSourceId(), game)) {
            Set<Card> cardsToMove = new LinkedHashSet<>();
            for (UUID targetId : targets.get(0).getTargets()) {
                mage.cards.Card targetCard = game.getCard(targetId);
                if (targetCard == null) {
                    return false;
                }
                cardsToMove.add(targetCard);
            }
            controller.moveCards(cardsToMove, Zone.HAND, ability, game);
            paid = true;
        }
    }
    return paid;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) UUID(java.util.UUID) Card(mage.cards.Card) Card(mage.cards.Card)

Aggregations

Card (mage.cards.Card)1448 Player (mage.players.Player)1096 Permanent (mage.game.permanent.Permanent)423 FilterCard (mage.filter.FilterCard)381 UUID (java.util.UUID)340 CardsImpl (mage.cards.CardsImpl)253 MageObject (mage.MageObject)212 FixedTarget (mage.target.targetpointer.FixedTarget)173 TargetCard (mage.target.TargetCard)165 Cards (mage.cards.Cards)159 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)111 ContinuousEffect (mage.abilities.effects.ContinuousEffect)99 TargetCardInHand (mage.target.common.TargetCardInHand)98 Target (mage.target.Target)86 HashSet (java.util.HashSet)85 FilterCreatureCard (mage.filter.common.FilterCreatureCard)84 ApprovingObject (mage.ApprovingObject)77 Ability (mage.abilities.Ability)71 TargetPlayer (mage.target.TargetPlayer)67 TargetPermanent (mage.target.TargetPermanent)64