Search in sources :

Example 21 with TargetCardInYourGraveyard

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

the class EccentricFarmerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.millCards(3, source, game);
    if (player.getGraveyard().count(StaticFilters.FILTER_CARD_LAND, game) < 1) {
        return true;
    }
    TargetCard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_LAND, true);
    player.choose(outcome, target, source.getSourceId(), game);
    player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 22 with TargetCardInYourGraveyard

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

the class ExperimentalOverloadEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int spellCount = player.getGraveyard().count(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, game);
    new WeirdToken2(spellCount).putOntoBattlefield(1, game, source, source.getControllerId());
    if (spellCount < 1) {
        return true;
    }
    TargetCard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, true);
    player.choose(outcome, player.getGraveyard(), target, game);
    return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) WeirdToken2(mage.game.permanent.token.WeirdToken2) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 23 with TargetCardInYourGraveyard

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

the class HaraldUnitesTheElvesTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.millCards(3, source, game);
    TargetCard targetCard = new TargetCardInYourGraveyard(0, 1, filter, true);
    player.choose(outcome, targetCard, source.getSourceId(), game);
    Card card = player.getGraveyard().get(targetCard.getFirstTarget(), game);
    if (card != null) {
        player.moveCards(card, Zone.BATTLEFIELD, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 24 with TargetCardInYourGraveyard

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

the class KingNarfisBetrayalSecondEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID controllerId = source.getControllerId();
    Player controller = game.getPlayer(controllerId);
    if (controller == null) {
        return false;
    }
    millEffect.apply(game, source);
    // Controller graveyard
    if (controller.getGraveyard().count(filter, game) != 0) {
        if (controller.chooseUse(outcome, "Exile a creature or planeswalker card from your graveyard?", source, game)) {
            TargetCard target = new TargetCardInYourGraveyard(filter);
            target.setNotTarget(true);
            if (controller.chooseTarget(outcome, controller.getGraveyard(), target, source, game)) {
                controller.moveCardsToExile(game.getCard(target.getFirstTarget()), source, game, true, CardUtil.getCardExileZoneId(game, source), CardUtil.createObjectRealtedWindowTitle(source, game, null));
            }
        }
    }
    // Each opponent's graveyard
    for (UUID opponentId : game.getOpponents(controllerId)) {
        Player opponent = game.getPlayer(opponentId);
        if (opponent == null) {
            continue;
        }
        if (opponent.getGraveyard().count(filter, game) != 0) {
            if (controller.chooseUse(outcome, "Exile a creature or planeswalker card from " + opponent.getName() + "'s graveyard?", source, game)) {
                TargetCard target = new TargetCardInOpponentsGraveyard(1, 1, filter, true);
                target.setNotTarget(true);
                if (controller.chooseTarget(outcome, opponent.getGraveyard(), target, source, game)) {
                    controller.moveCardsToExile(game.getCard(target.getFirstTarget()), source, game, true, CardUtil.getCardExileZoneId(game, source), CardUtil.createObjectRealtedWindowTitle(source, game, null));
                }
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCardInOpponentsGraveyard(mage.target.common.TargetCardInOpponentsGraveyard) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID)

Example 25 with TargetCardInYourGraveyard

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

the class SequesteredStashEffect 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(new FilterArtifactCard("artifact card from your graveyard"));
    target.setNotTarget(true);
    if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.chooseUse(outcome, "Put an artifact card from your graveyard to library?", source, game) && controller.choose(outcome, target, source.getSourceId(), game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            controller.moveCards(card, Zone.LIBRARY, source, game);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterArtifactCard(mage.filter.common.FilterArtifactCard) Card(mage.cards.Card) FilterArtifactCard(mage.filter.common.FilterArtifactCard)

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