Search in sources :

Example 31 with TargetCardInExile

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;
}
Also used : Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) TargetCardInExile(mage.target.common.TargetCardInExile) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 32 with TargetCardInExile

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;
}
Also used : Player(mage.players.Player) mage.cards(mage.cards) Objects(java.util.Objects) TargetCardInExile(mage.target.common.TargetCardInExile) ExileZone(mage.game.ExileZone) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) TargetCard(mage.target.TargetCard)

Aggregations

TargetCardInExile (mage.target.common.TargetCardInExile)32 Player (mage.players.Player)31 FilterCard (mage.filter.FilterCard)17 TargetCard (mage.target.TargetCard)13 Card (mage.cards.Card)11 ApprovingObject (mage.ApprovingObject)10 Cards (mage.cards.Cards)6 Target (mage.target.Target)6 CardsImpl (mage.cards.CardsImpl)5 UUID (java.util.UUID)3 FilterOwnedCard (mage.filter.common.FilterOwnedCard)3 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)3 ExileZone (mage.game.ExileZone)3 FilterInstantOrSorceryCard (mage.filter.common.FilterInstantOrSorceryCard)2 Permanent (mage.game.permanent.Permanent)2 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 ArrayList (java.util.ArrayList)1 Objects (java.util.Objects)1 MageObject (mage.MageObject)1