Search in sources :

Example 66 with TargetCardInYourGraveyard

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

the class ForbiddenCryptPutIntoYourGraveyardReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        boolean cardReturned = false;
        TargetCardInYourGraveyard target = new TargetCardInYourGraveyard();
        target.setNotTarget(true);
        if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
            if (target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game)) {
                Card card = game.getCard(target.getFirstTarget());
                if (card != null) {
                    controller.moveCards(card, Zone.HAND, source, game);
                    cardReturned = true;
                }
            }
        }
        if (!cardReturned) {
            game.informPlayers(controller.getLogName() + " can't return a card from graveyard to hand.");
            controller.lost(game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card)

Example 67 with TargetCardInYourGraveyard

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

the class GrimCaptainsCallEffect method returnToHand.

private void returnToHand(Game game, SubType subType, Player controller, Ability source) {
    FilterCreatureCard filter = new FilterCreatureCard(subType.getDescription() + " card");
    filter.add(subType.getPredicate());
    TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard(filter));
    if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
        if (controller.chooseTarget(outcome, target, source, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                controller.moveCards(card, Zone.HAND, source, game);
            }
        }
    }
}
Also used : FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 68 with TargetCardInYourGraveyard

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

the class InfernalOfferingReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetOpponent(true);
        target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), game);
        Player opponent = game.getPlayer(target.getFirstTarget());
        target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
        if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), game)) {
            Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
        if (opponent != null) {
            target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
            if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), game)) {
                Card card = opponent.getGraveyard().get(target.getFirstTarget(), game);
                if (card != null) {
                    opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetOpponent(mage.target.common.TargetOpponent) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 69 with TargetCardInYourGraveyard

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

the class MantleOfTheAncientsPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = source.getSourcePermanentOrLKI(game);
    if (player == null || sourcePermanent == null) {
        return false;
    }
    Permanent permanent = game.getPermanent(sourcePermanent.getAttachedTo());
    if (permanent == null) {
        return false;
    }
    FilterCard filter = new FilterCard("Aura or Equipment card that can be attached to " + permanent.getName());
    filter.add(new MantleOfTheAncientsPredicate(permanent));
    TargetCard target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter, true);
    player.choose(outcome, target, source.getSourceId(), game);
    Cards cards = new CardsImpl(target.getTargets());
    if (cards.isEmpty()) {
        return false;
    }
    cards.getCards(game).stream().forEach(card -> game.getState().setValue("attachTo:" + card.getId(), permanent));
    player.moveCards(cards, Zone.BATTLEFIELD, source, game);
    for (UUID cardId : cards) {
        permanent.addAttachment(cardId, source, game);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID)

Example 70 with TargetCardInYourGraveyard

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

the class RelentlessDeadEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseUse(Outcome.Benefit, "Do you want to pay {X} to return zombie?", source, game)) {
            int payCount = ManaUtil.playerPaysXGenericMana(true, "Relentless Dead", controller, source, game);
            // can be 0
            FilterCard filter = new FilterCard("Another target Zombie card with mana value {" + payCount + "}");
            filter.add(SubType.ZOMBIE.getPredicate());
            filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, payCount));
            filter.add(new AnotherCardPredicate());
            TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
            if (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) AnotherCardPredicate(mage.filter.predicate.mageobject.AnotherCardPredicate) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

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