use of mage.target.common.TargetCardInExile in project mage by magefree.
the class BlightHerderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetCardInExile(2, 2, filter, null);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
if (controller.chooseTarget(outcome, target, source, game)) {
Cards cardsToGraveyard = new CardsImpl(target.getTargets());
controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
return new CreateTokenEffect(new EldraziScionToken(), 3).apply(game, source);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class ReturnSengirNosferatuEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Target target = new TargetCardInExile(filter);
target.setNotTarget(true);
if (!target.canChoose(source.getSourceId(), controller.getId(), game)) {
return false;
}
controller.chooseTarget(Outcome.PutCreatureInPlay, target, source, game);
Card card = game.getCard(target.getTargets().get(0));
if (card != null) {
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
return false;
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class EmergentUltimatumTarget method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCardInLibrary targetCardInLibrary = new EmergentUltimatumTarget();
targetCardInLibrary.setNotTarget(true);
boolean searched = player.searchLibrary(targetCardInLibrary, source, game);
Cards cards = new CardsImpl(targetCardInLibrary.getTargets());
player.moveCards(cards, Zone.EXILED, source, game);
if (cards.isEmpty()) {
if (searched) {
player.shuffleLibrary(source, game);
}
return false;
}
TargetOpponent targetOpponent = new TargetOpponent();
targetOpponent.setNotTarget(true);
player.choose(outcome, targetOpponent, source.getSourceId(), game);
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent == null) {
if (searched) {
player.shuffleLibrary(source, game);
}
return false;
}
TargetCardInExile targetCardInExile = new TargetCardInExile(StaticFilters.FILTER_CARD);
targetCardInExile.setNotTarget(true);
opponent.choose(outcome, cards, targetCardInExile, game);
Card toShuffle = game.getCard(targetCardInExile.getFirstTarget());
if (toShuffle != null) {
player.putCardsOnBottomOfLibrary(toShuffle, game, source, false);
player.shuffleLibrary(source, game);
cards.remove(toShuffle);
}
while (!cards.isEmpty()) {
if (!player.chooseUse(Outcome.PlayForFree, "Cast an exiled card without paying its mana cost?", source, game)) {
break;
}
targetCardInExile.clearChosen();
if (!player.choose(Outcome.PlayForFree, cards, targetCardInExile, game)) {
continue;
}
Card card = game.getCard(targetCardInExile.getFirstTarget());
if (card == null) {
continue;
}
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
Boolean cardWasCast = player.cast(player.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
// remove on non cast too (infinite freeze fix)
cards.remove(card);
if (cardWasCast) {
cards.remove(card);
} else {
game.informPlayer(player, "You're not able to cast " + card.getIdName() + " or you canceled the casting.");
}
}
return true;
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class EndlessHorizonsEffect2 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCard target = new TargetCardInExile(0, 1, filter, CardUtil.getExileZoneId(game, source));
target.setNotTarget(true);
controller.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
return card != null && controller.moveCards(card, Zone.HAND, source, game);
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class MagmaticChannelerCastFromExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 2));
player.moveCards(cards, Zone.EXILED, source, game);
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
Card card = null;
if (cards.isEmpty()) {
return false;
} else if (cards.size() == 1) {
card = cards.getRandom(game);
} else {
TargetCard targetCard = new TargetCardInExile(StaticFilters.FILTER_CARD, null);
player.choose(outcome, cards, targetCard, game);
card = game.getCard(targetCard.getFirstTarget());
}
if (card == null) {
return false;
}
game.addEffect(new MagmaticChannelerCastFromExileEffect(new MageObjectReference(card, game)), source);
return true;
}
Aggregations