use of mage.cards.CardsImpl in project mage by magefree.
the class ExileFromHandCost method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
if (targets.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
Player player = game.getPlayer(controllerId);
int cmc = 0;
for (UUID targetId : targets.get(0).getTargets()) {
Card card = player.getHand().get(targetId, game);
if (card == null) {
return false;
}
cmc += card.getManaValue();
this.cards.add(card);
}
Cards cardsToExile = new CardsImpl();
cardsToExile.addAll(cards);
player.moveCards(cardsToExile, Zone.EXILED, ability, game);
paid = true;
if (setXFromCMC) {
VariableManaCost vmc = new VariableManaCost(VariableCostType.ALTERNATIVE);
// no x events - rules from Unbound Flourishing:
// - Spells with additional costs that include X won't be affected by Unbound Flourishing. X must be in the spell's mana cost.
// TODO: wtf, look at setXFromCMC usage -- it used in cards with alternative costs, not additional... need to fix?
vmc.setAmount(cmc, cmc, false);
vmc.setPaid();
ability.getManaCostsToPay().add(vmc);
}
}
return paid;
}
use of mage.cards.CardsImpl 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.CardsImpl in project mage by magefree.
the class DiscardTargetCost method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
this.cards.clear();
this.targets.clearChosen();
Player player = game.getPlayer(controllerId);
if (player == null) {
return false;
}
int amount = this.getTargets().get(0).getNumberOfTargets();
if (randomDiscard) {
this.cards.addAll(player.discard(amount, true, true, source, game).getCards(game));
} else if (targets.choose(Outcome.Discard, controllerId, source.getSourceId(), game)) {
Cards toDiscard = new CardsImpl();
toDiscard.addAll(targets.get(0).getTargets());
Cards discarded = player.discard(toDiscard, true, source, game);
if (!discarded.isEmpty()) {
cards.addAll(discarded.getCards(game));
}
}
paid = cards.size() >= amount;
return paid;
}
use of mage.cards.CardsImpl 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.CardsImpl in project mage by magefree.
the class ReturnToBattlefieldUnderYourControlTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToBattlefield = new CardsImpl();
if (returnFromExileZoneOnly) {
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
UUID mainCardId = CardUtil.getMainCardId(game, targetId);
if (game.getExile().containsId(mainCardId, game)) {
cardsToBattlefield.add(mainCardId);
} else {
Card card = game.getCard(targetId);
if (card instanceof MeldCard) {
MeldCard meldCard = (MeldCard) card;
Card topCard = meldCard.getTopHalfCard();
Card bottomCard = meldCard.getBottomHalfCard();
if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter() && game.getExile().containsId(topCard.getId(), game)) {
cardsToBattlefield.add(topCard);
}
if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter() && game.getExile().containsId(bottomCard.getId(), game)) {
cardsToBattlefield.add(bottomCard);
}
}
}
}
} else {
cardsToBattlefield.addAll(getTargetPointer().getTargets(game, source));
}
for (Card card : cardsToBattlefield.getCards(game)) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null)) {
if (attacking) {
game.getCombat().addAttackingCreature(card.getId(), game);
}
}
}
return true;
}
return false;
}
Aggregations