Search in sources :

Example 61 with TargetCardInYourGraveyard

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

the class RadiantScrollwielderWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || player.getGraveyard().count(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, game) < 1) {
        return false;
    }
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY);
    target.setNotTarget(true);
    target.setRandom(true);
    target.chooseTarget(outcome, player.getId(), source, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return false;
    }
    PlayFromNotOwnHandZoneTargetEffect.exileAndPlayFromExile(game, source, card, TargetController.YOU, Duration.EndOfTurn, false, false, true);
    game.addEffect(new RadiantScrollwielderReplacementEffect(card, game), source);
    return true;
}
Also used : Player(mage.players.Player) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card)

Example 62 with TargetCardInYourGraveyard

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

the class RofellossGiftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filter1);
    if (!player.choose(outcome, player.getHand(), targetCardInHand, game)) {
        return false;
    }
    Cards cards = new CardsImpl();
    for (UUID cardId : targetCardInHand.getTargets()) {
        Card card = game.getCard(cardId);
        if (card != null) {
            cards.add(card);
        }
    }
    player.revealCards(source, cards, game);
    int enchantmentsToReturn = Math.min(player.getGraveyard().count(filter2, game), targetCardInHand.getTargets().size());
    TargetCardInYourGraveyard targetCardInYourGraveyard = new TargetCardInYourGraveyard(enchantmentsToReturn, filter2);
    targetCardInYourGraveyard.setNotTarget(true);
    if (!player.choose(outcome, targetCardInYourGraveyard, source.getSourceId(), game)) {
        return false;
    }
    cards = new CardsImpl();
    for (UUID cardId : targetCardInYourGraveyard.getTargets()) {
        Card card = game.getCard(cardId);
        if (card != null) {
            cards.add(card);
        }
    }
    return player.moveCards(cards, Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard)

Example 63 with TargetCardInYourGraveyard

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

the class WebOfInertiaRestrictionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (player != null && sourceObject != null) {
        Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard());
        if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Detriment, "Exile a card from your graveyard?", source, game)) {
            cost.clearPaid();
            if (cost.pay(source, game, source, player.getId(), false, null)) {
                if (!game.isSimulation()) {
                    game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
                }
            }
        } else {
            game.addEffect(new WebOfInertiaRestrictionEffect(player.getId()), source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) MageObject(mage.MageObject) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Cost(mage.abilities.costs.Cost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost)

Example 64 with TargetCardInYourGraveyard

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

the class WitherbloomCommandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCard target = new TargetCardInYourGraveyard(1, StaticFilters.FILTER_CARD_LAND);
    target.setNotTarget(true);
    if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
        return false;
    }
    player.choose(outcome, target, source.getSourceId(), game);
    Card card = game.getCard(target.getFirstTarget());
    return card != null && player.moveCards(card, Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 65 with TargetCardInYourGraveyard

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

the class ExileCardFromOwnGraveyardControllerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || player.getGraveyard().isEmpty()) {
        return false;
    }
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(Math.min(amount, player.getGraveyard().size()), StaticFilters.FILTER_CARD);
    target.setNotTarget(true);
    if (!player.chooseTarget(outcome, target, source, game)) {
        return true;
    }
    Cards cards = new CardsImpl();
    for (UUID targetId : target.getTargets()) {
        cards.add(player.getGraveyard().get(targetId, game));
    }
    return player.moveCards(cards, Zone.EXILED, source, game);
}
Also used : Player(mage.players.Player) 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