use of mage.cards.Cards in project mage by magefree.
the class PsychoticEpisodeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (player != null && controller != null && sourceObject != null) {
TargetCard targetCard = new TargetCard(Zone.ALL, new FilterCard());
targetCard.setRequired(true);
Cards options = player.getHand().copy();
Card topdeck = player.getLibrary().getFromTop(game);
options.add(topdeck);
controller.lookAtCards("Top of Library (Psychotic Episode)", topdeck, game);
if (controller.choose(Outcome.Discard, options, targetCard, game)) {
Card card = game.getCard(targetCard.getFirstTarget());
if (card != null) {
CardsImpl cards = new CardsImpl();
cards.add(card);
player.revealCards(sourceObject.getIdName(), cards, game);
player.putCardsOnBottomOfLibrary(cards, game, source, true);
}
}
return true;
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class SifterWurmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
controller.scry(3, source, game);
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
controller.revealCards(sourceObject.getIdName(), cards, game);
controller.gainLife(card.getManaValue(), game, source);
}
return true;
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class SuddenReclamationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToHand = new CardsImpl();
Target target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cardsToHand.add(card);
}
}
target = new TargetCardInYourGraveyard(new FilterLandCard("land card from your graveyard"));
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cardsToHand.add(card);
}
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
return true;
}
return false;
}
use of mage.cards.Cards in project mage by magefree.
the class VarragothBloodskySireEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
if (player.searchLibrary(target, source, game)) {
Cards foundCards = new CardsImpl(target.getTargets());
player.shuffleLibrary(source, game);
player.putCardsOnTopOfLibrary(foundCards, game, source, false);
return true;
}
player.shuffleLibrary(source, game);
}
return false;
}
use of mage.cards.Cards 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;
}
Aggregations