use of mage.target.common.TargetCardInExile in project mage by magefree.
the class DimensionalBreachReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(morSet.stream().map(mor -> mor.getCard(game)).filter(Objects::nonNull).filter(c -> c.isOwnedBy(game.getActivePlayerId())).collect(Collectors.toSet()));
if (cards.isEmpty()) {
return false;
}
if (cards.size() > 1) {
TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD);
target.setNotTarget(true);
player.choose(outcome, cards, target, game);
cards.clear();
cards.add(target.getFirstTarget());
}
return player.moveCards(cards, Zone.BATTLEFIELD, source, game);
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class BagOfDevouringEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int result = player.rollDice(Outcome.Benefit, source, game, 10);
TargetCard target = new TargetCardInExile(0, result, StaticFilters.FILTER_CARD, CardUtil.getExileZoneId(game, source));
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
return true;
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class JestersScepterCounterEffect 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) {
TargetCardInExile target = new TargetCardInExile(new FilterCard(), CardUtil.getCardExileZoneId(game, ability));
target.setNotTarget(true);
Cards cards = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, ability));
if (cards != null && !cards.isEmpty() && controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.moveCardToGraveyardWithInfo(card, source, game, Zone.EXILED)) {
if (card instanceof SplitCard) {
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", ((SplitCard) card).getLeftHalfCard().getName());
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment2", ((SplitCard) card).getRightHalfCard().getName());
} else if (card instanceof ModalDoubleFacesCard) {
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", ((ModalDoubleFacesCard) card).getLeftHalfCard().getName());
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment2", ((ModalDoubleFacesCard) card).getRightHalfCard().getName());
} else {
game.getState().setValue(source.getSourceId() + "_nameOfExiledCardPayment", card.getName());
}
paid = true;
}
}
}
}
return paid;
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class JelevaNephaliasWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
if (exileZone != null && exileZone.count(new FilterInstantOrSorceryCard(), game) > 0) {
if (controller.chooseUse(outcome, "Cast an instant or sorcery card from " + "exile without paying its mana cost?", source, game)) {
TargetCardInExile target = new TargetCardInExile(new FilterInstantOrSorceryCard(), CardUtil.getCardExileZoneId(game, source));
if (controller.choose(Outcome.PlayForFree, exileZone, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
return cardWasCast;
}
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class VoidMawCost 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) {
TargetCardInExile target = new TargetCardInExile(new FilterCard(), CardUtil.getCardExileZoneId(game, ability));
target.setNotTarget(true);
Cards cards = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, ability));
if (cards != null && !cards.isEmpty() && controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.moveCardToGraveyardWithInfo(card, source, game, Zone.EXILED)) {
paid = true;
}
}
}
}
return paid;
}
Aggregations