use of mage.target.common.TargetCardInExile in project mage by magefree.
the class AshiokNightmareMuseCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCardInExile target = new TargetCardInExile(0, 3, filter, null);
target.setNotTarget(true);
if (!controller.chooseTarget(outcome, target, source, game)) {
// method is fine, controller is still choosing the card
return false;
}
for (UUID targetId : target.getTargets()) {
if (targetId != null) {
Card chosenCard = game.getCard(targetId);
if (chosenCard != null && // must be exiled
game.getState().getZone(chosenCard.getId()) == Zone.EXILED && // must be owned by an opponent
game.getOpponents(controller.getId()).contains(chosenCard.getOwnerId()) && controller.chooseUse(outcome, "Cast " + chosenCard.getName() + " without paying its mana cost?", source, game)) {
game.getState().setValue("PlayFromNotOwnHandZone" + chosenCard.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(chosenCard, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + chosenCard.getId(), null);
}
}
}
return true;
}
use of mage.target.common.TargetCardInExile in project mage by magefree.
the class AuthorOfShadowsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
game.getOpponents(source.getControllerId()).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).forEach(cards::addAll);
cards.removeIf(Objects::isNull);
if (cards.isEmpty()) {
return false;
}
controller.moveCards(cards, Zone.EXILED, source, game);
cards.retainZone(Zone.EXILED, game);
if (cards.isEmpty()) {
return false;
}
TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD_A_NON_LAND);
target.setNotTarget(true);
controller.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return true;
}
// use same player's zone for all Author of Shadows instances
String exileZoneName = controller.getName() + " - Author of Shadows - cast with any color";
UUID exileZoneId = CardUtil.getExileZoneId(exileZoneName, game);
ExileZone exileZone = game.getExile().createZone(exileZoneId, exileZoneName);
game.getExile().moveToAnotherZone(card, game, exileZone);
CardUtil.makeCardPlayable(game, source, card, Duration.Custom, true);
return true;
}
Aggregations