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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations