Search in sources :

Example 76 with TargetCardInYourGraveyard

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

the class ImmortalCoilPreventionEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    if (game.replaceEvent(new PreventDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage()))) {
        return false;
    }
    int damage = event.getAmount();
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(Math.min(damage, player.getGraveyard().size()), StaticFilters.FILTER_CARD);
        target.setNotTarget(true);
        player.choose(outcome, target, source.getSourceId(), game);
        player.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
    }
    event.setAmount(0);
    game.fireEvent(new PreventedDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), damage));
    return false;
}
Also used : Player(mage.players.Player) PreventedDamageEvent(mage.game.events.PreventedDamageEvent) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) PreventedDamageEvent(mage.game.events.PreventedDamageEvent) DamageEvent(mage.game.events.DamageEvent) PreventDamageEvent(mage.game.events.PreventDamageEvent) PreventDamageEvent(mage.game.events.PreventDamageEvent) CardsImpl(mage.cards.CardsImpl)

Example 77 with TargetCardInYourGraveyard

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

the class MissionBriefingReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.surveil(2, source, game);
    Target target = new TargetCardInYourGraveyard(new FilterInstantOrSorceryCard("instant or sorcery card from your graveyard"));
    if (!player.choose(outcome, target, source.getSourceId(), game)) {
        return true;
    }
    Card card = game.getCard(target.getFirstTarget());
    if (card != null) {
        ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect();
        effect.setTargetPointer(new FixedTarget(card, game));
        game.addEffect(effect, source);
        effect = new MissionBriefingReplacementEffect(card.getId());
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) Card(mage.cards.Card)

Example 78 with TargetCardInYourGraveyard

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

the class NefariousLichLifeGainReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(event.getPlayerId());
    if (controller != null) {
        Target target = new TargetCardInYourGraveyard(amount, new FilterCard("card in your graveyard"));
        if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
            if (controller.choose(Outcome.Exile, target, source.getSourceId(), game)) {
                Set<Card> cards = new HashSet<>(amount);
                for (UUID targetId : target.getTargets()) {
                    Card card = controller.getGraveyard().get(targetId, game);
                    if (card != null) {
                        cards.add(card);
                    }
                }
                controller.moveCardsToExile(cards, source, game, true, null, "");
                return true;
            }
        }
        controller.lost(game);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Target(mage.target.Target) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 79 with TargetCardInYourGraveyard

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

the class SwiftWarkiteEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        if (controller.chooseUse(Outcome.PutCardInPlay, "Put a creature card from your hand? (No = from your graveyard)", source, game)) {
            Target target = new TargetCardInHand(0, 1, filter);
            controller.choose(outcome, target, source.getSourceId(), game);
            Card card = controller.getHand().get(target.getFirstTarget(), game);
            if (card != null) {
                if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                    Permanent creature = game.getPermanent(card.getId());
                    if (creature != null) {
                        ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                        effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
                        game.addEffect(effect, source);
                        Effect effect2 = new ReturnToHandTargetEffect();
                        effect2.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
                        DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect2);
                        game.addDelayedTriggeredAbility(delayedAbility, source);
                    }
                }
            }
        } else {
            Target target = new TargetCardInYourGraveyard(0, 1, filter);
            target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game);
            Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
                Permanent creature = game.getPermanent(card.getId());
                if (creature != null) {
                    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
                    effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
                    game.addEffect(effect, source);
                    Effect effect2 = new ReturnToHandTargetEffect();
                    effect2.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
                    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect2);
                    game.addDelayedTriggeredAbility(delayedAbility, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect)

Example 80 with TargetCardInYourGraveyard

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

the class VenerableWarsingerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player player = game.getPlayer(event.getPlayerId());
    if (player == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    FilterCard filter = new FilterCreatureCard("creature card with mana value " + event.getAmount() + " less from your graveyard");
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, event.getAmount() + 1));
    this.getTargets().clear();
    this.addTarget(new TargetCardInYourGraveyard(filter));
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) DamagedEvent(mage.game.events.DamagedEvent) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

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