Search in sources :

Example 51 with TargetCardInGraveyard

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

the class TheMimeoplasmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanentEntering(source.getSourceId());
    if (controller != null && permanent != null) {
        if (new CardsInAllGraveyardsCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this) >= 2) {
            if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
                TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of"));
                targetCopy.setNotTarget(true);
                if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) {
                    Card cardToCopy = game.getCard(targetCopy.getFirstTarget());
                    if (cardToCopy != null) {
                        FilterCreatureCard filter = new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters");
                        filter.add(Predicates.not(new CardIdPredicate(cardToCopy.getId())));
                        TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(filter);
                        targetCounters.setNotTarget(true);
                        if (controller.choose(Outcome.Copy, targetCounters, source.getSourceId(), game)) {
                            Card cardForCounters = game.getCard(targetCounters.getFirstTarget());
                            if (cardForCounters != null) {
                                Cards cardsToExile = new CardsImpl();
                                cardsToExile.add(cardToCopy);
                                cardsToExile.add(cardForCounters);
                                controller.moveCards(cardsToExile, Zone.EXILED, source, game);
                                CopyEffect copyEffect = new CopyEffect(Duration.Custom, cardToCopy, source.getSourceId());
                                game.addEffect(copyEffect, source);
                                permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), source.getControllerId(), source, game);
                            }
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : CopyEffect(mage.abilities.effects.common.CopyEffect) Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Permanent(mage.game.permanent.Permanent) CardsInAllGraveyardsCount(mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount) FilterCreatureCard(mage.filter.common.FilterCreatureCard) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Example 52 with TargetCardInGraveyard

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

the class EnteringReturnFromGraveyardToBattlefieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetCardInGraveyard(StaticFilters.FILTER_CARD_CREATURE);
        target.setNotTarget(true);
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.chooseTarget(outcome, target, source, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(card.getId(), game));
                    game.addEffect(effect, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SplitCard(mage.cards.SplitCard) Card(mage.cards.Card)

Example 53 with TargetCardInGraveyard

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

the class CreepingInnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = source.getSourcePermanentOrLKI(game);
    if (player != null && permanent != null) {
        UUID exileId = CardUtil.getExileZoneId(game, source);
        TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
        target.setNotTarget(true);
        if (target.canChoose(source.getSourceId(), player.getId(), game)) {
            if (player.choose(Outcome.Exile, target, source.getId(), game)) {
                Card cardChosen = game.getCard(target.getFirstTarget());
                if (cardChosen != null) {
                    int lifeAmount = 0;
                    player.moveCardsToExile(cardChosen, source, game, true, exileId, permanent.getName());
                    ExileZone exile = game.getExile().getExileZone(exileId);
                    if (exile != null) {
                        for (UUID cardId : exile) {
                            lifeAmount++;
                        }
                    }
                    for (UUID playerId : game.getOpponents(source.getControllerId())) {
                        game.getPlayer(playerId).loseLife(lifeAmount, game, source, false);
                    }
                    player.gainLife(lifeAmount, game, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Permanent(mage.game.permanent.Permanent) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) Card(mage.cards.Card)

Example 54 with TargetCardInGraveyard

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

the class CemeteryGatekeeperTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        TargetCardInGraveyard target = new TargetCardInGraveyard();
        target.setNotTarget(true);
        controller.choose(outcome, target, source.getSourceId(), game);
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
            MageObject sourceObject = source.getSourceObject(game);
            String exileName = sourceObject == null ? null : sourceObject.getIdName();
            return controller.moveCardsToExile(card, source, game, true, exileId, exileName);
        }
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) MageObject(mage.MageObject) UUID(java.util.UUID) Card(mage.cards.Card)

Example 55 with TargetCardInGraveyard

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

the class CemeteryIlluminatorWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        TargetCardInGraveyard target = new TargetCardInGraveyard();
        target.setNotTarget(true);
        controller.choose(outcome, target, source.getSourceId(), game);
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
            MageObject sourceObject = source.getSourceObject(game);
            String exileName = sourceObject == null ? null : sourceObject.getIdName();
            return controller.moveCardsToExile(card, source, game, true, exileId, exileName);
        }
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) MageObject(mage.MageObject) UUID(java.util.UUID) Card(mage.cards.Card)

Aggregations

TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)59 Player (mage.players.Player)54 Card (mage.cards.Card)32 FilterCard (mage.filter.FilterCard)24 OwnerIdPredicate (mage.filter.predicate.card.OwnerIdPredicate)23 UUID (java.util.UUID)21 FilterCreatureCard (mage.filter.common.FilterCreatureCard)17 Permanent (mage.game.permanent.Permanent)14 Target (mage.target.Target)14 TargetCard (mage.target.TargetCard)12 MageObject (mage.MageObject)8 Ability (mage.abilities.Ability)6 CardsImpl (mage.cards.CardsImpl)6 CardIdPredicate (mage.filter.predicate.mageobject.CardIdPredicate)5 TargetPlayer (mage.target.TargetPlayer)5 HashSet (java.util.HashSet)4 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)4 Cards (mage.cards.Cards)4 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)4 TargetOpponent (mage.target.common.TargetOpponent)4