Search in sources :

Example 6 with TargetCardInExile

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;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetCardInExile(mage.target.common.TargetCardInExile) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) EldraziScionToken(mage.game.permanent.token.EldraziScionToken) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 7 with TargetCardInExile

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

Example 8 with TargetCardInExile

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;
}
Also used : Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) ApprovingObject(mage.ApprovingObject) TargetCardInExile(mage.target.common.TargetCardInExile) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard)

Example 9 with TargetCardInExile

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);
}
Also used : Player(mage.players.Player) TargetCardInExile(mage.target.common.TargetCardInExile) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

Example 10 with TargetCardInExile

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;
}
Also used : Player(mage.players.Player) TargetCardInExile(mage.target.common.TargetCardInExile) TargetCard(mage.target.TargetCard) MageObjectReference(mage.MageObjectReference) 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