Search in sources :

Example 81 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class KayaTheInexorableEmblemEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        Choice zoneChoice = new ChoiceImpl(true);
        zoneChoice.setMessage("Cast a legendary spell from hand, graveyard, or exile");
        zoneChoice.setChoices(choices);
        zoneChoice.clearChoice();
        if (player.choose(Outcome.PlayForFree, zoneChoice, game)) {
            TargetCard target = null;
            switch(zoneChoice.getChoice()) {
                case "Hand":
                    target = new TargetCardInHand(0, 1, filter);
                    target.setTargetName("legendary spell from your hand");
                    break;
                case "Graveyard":
                    target = new TargetCardInYourGraveyard(0, 1, filter, true);
                    target.setTargetName("legendary spell from your graveyard");
                    break;
                case "Exile":
                    target = new TargetCardInExile(0, 1, filter, null, true);
                    target.setNotTarget(true);
                    target.setTargetName("legendary spell you own in exile");
                    break;
            }
            if (target != null && player.chooseTarget(Outcome.PlayForFree, target, source, game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    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);
                    return cardWasCast;
                }
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) ApprovingObject(mage.ApprovingObject) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCardInExile(mage.target.common.TargetCardInExile) ChoiceImpl(mage.choices.ChoiceImpl) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterOwnedCard(mage.filter.common.FilterOwnedCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 82 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class AraumiOfTheDeadTideCost method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player player = game.getPlayer(controllerId);
    if (player == null) {
        return paid;
    }
    int oppCount = game.getOpponents(controllerId).size();
    TargetCard target = new TargetCardInYourGraveyard(oppCount, StaticFilters.FILTER_CARD);
    target.setNotTarget(true);
    player.choose(Outcome.Exile, target, source.getSourceId(), game);
    Cards cards = new CardsImpl(target.getTargets());
    if (cards.size() < oppCount) {
        return paid;
    }
    player.moveCards(cards, Zone.EXILED, ability, game);
    paid = cards.stream().map(game.getState()::getZone).filter(Zone.EXILED::equals).count() >= oppCount;
    return paid;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 83 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class BloodOnTheSnowEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int snow = ManaPaidSourceWatcher.getSnowPaid(source.getId(), game);
        FilterCard filter = new FilterCard("a creature or planeswalker card with mana value " + snow + " or less from your graveyard");
        filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.PLANESWALKER.getPredicate()));
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, snow + 1));
        TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter, true);
        controller.chooseTarget(outcome, target, source, game);
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            return true;
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 84 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class CruelUltimatumEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
    if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card == null) {
            return false;
        }
        return controller.moveCards(card, Zone.HAND, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card)

Example 85 with TargetCardInYourGraveyard

use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.

the class BondOfInsightEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        player.millCards(4, source, game);
    }
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCard target = new TargetCardInYourGraveyard(0, 2, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, true);
    if (!player.choose(outcome, target, source.getSourceId(), game)) {
        return false;
    }
    Cards cards = new CardsImpl(target.getTargets());
    return player.moveCards(cards, Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Aggregations

TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)88 Player (mage.players.Player)78 Card (mage.cards.Card)47 FilterCard (mage.filter.FilterCard)38 TargetCard (mage.target.TargetCard)29 CardsImpl (mage.cards.CardsImpl)18 UUID (java.util.UUID)16 Target (mage.target.Target)16 Permanent (mage.game.permanent.Permanent)14 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)11 FilterCreatureCard (mage.filter.common.FilterCreatureCard)10 TargetCardInHand (mage.target.common.TargetCardInHand)10 Cards (mage.cards.Cards)9 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)7 MageObject (mage.MageObject)6 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)5 HashSet (java.util.HashSet)4 ExileFromGraveCost (mage.abilities.costs.common.ExileFromGraveCost)4 OneShotEffect (mage.abilities.effects.OneShotEffect)4 FixedTarget (mage.target.targetpointer.FixedTarget)4