Search in sources :

Example 1 with TargetCardInExile

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

Example 2 with TargetCardInExile

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

Example 3 with TargetCardInExile

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

Example 4 with TargetCardInExile

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

Example 5 with TargetCardInExile

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

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