use of mage.cards.Cards 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.Cards 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.Cards 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.Cards 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;
}
use of mage.cards.Cards in project mage by magefree.
the class ReturnToBattlefieldUnderOwnerControlTargetEffect 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)) {
if (game.getExile().containsId(targetId, game)) {
cardsToBattlefield.add(targetId);
} 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));
}
if (!cardsToBattlefield.isEmpty()) {
controller.moveCards(cardsToBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, tapped, false, true, null);
}
return true;
}
return false;
}
Aggregations