Search in sources :

Example 21 with TargetCardInExile

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

the class ReturnSengirNosferatuEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Target target = new TargetCardInExile(filter);
    target.setNotTarget(true);
    if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
        return false;
    }
    player.chooseTarget(Outcome.PutCreatureInPlay, target, source, game);
    Card card = game.getCard(target.getFirstTarget());
    return card != null && player.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetCardInExile(mage.target.common.TargetCardInExile) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 22 with TargetCardInExile

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

the class KahoMinamoHistorianCastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        FilterCard filter = new FilterCard();
        filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, source.getManaCostsToPay().getX()));
        TargetCardInExile target = new TargetCardInExile(filter, CardUtil.getCardExileZoneId(game, source));
        Cards cards = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
        if (cards != null && !cards.isEmpty() && controller.choose(Outcome.PlayForFree, cards, target, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) ApprovingObject(mage.ApprovingObject) TargetCardInExile(mage.target.common.TargetCardInExile) FilterCard(mage.filter.FilterCard)

Example 23 with TargetCardInExile

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

the class TargetYouPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller != null && sourcePermanent != null) {
        TargetCardInExile target = new TargetCardInExile(new FilterCard(), CardUtil.getExileZoneId(game, source.getSourceId(), sourcePermanent.getZoneChangeCounter(game)));
        if (controller.choose(Outcome.PlayForFree, game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), sourcePermanent.getZoneChangeCounter(game))), target, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null && controller.chooseUse(outcome, "Cast " + card.getLogName() + " without paying its mana cost?", source, game)) {
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
                return cardWasCast;
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer) ApprovingObject(mage.ApprovingObject) Permanent(mage.game.permanent.Permanent) TargetCardInExile(mage.target.common.TargetCardInExile) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 24 with TargetCardInExile

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

the class UlamogsNullifierEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Spell spell = game.getStack().getSpell(source.getFirstTarget());
    if (controller != null && spell != null) {
        Target target = new TargetCardInExile(2, 2, filter, null);
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
            if (controller.chooseTarget(outcome, target, source, game)) {
                Cards cardsToGraveyard = new CardsImpl(target.getTargets());
                controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
                game.getStack().counter(source.getFirstTarget(), source, game);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetCardInExile(mage.target.common.TargetCardInExile) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 25 with TargetCardInExile

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

the class UlamogsDespoilerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetCardInExile(2, 2, filter, null);
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
            if (controller.chooseTarget(outcome, target, source, game)) {
                Cards cardsToGraveyard = new CardsImpl(target.getTargets());
                controller.moveCards(cardsToGraveyard, Zone.GRAVEYARD, source, game);
                return new AddCountersSourceEffect(CounterType.P1P1.createInstance(4)).apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Player(mage.players.Player) Target(mage.target.Target) TargetCardInExile(mage.target.common.TargetCardInExile) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Aggregations

TargetCardInExile (mage.target.common.TargetCardInExile)32 Player (mage.players.Player)31 FilterCard (mage.filter.FilterCard)17 TargetCard (mage.target.TargetCard)13 Card (mage.cards.Card)11 ApprovingObject (mage.ApprovingObject)10 Cards (mage.cards.Cards)6 Target (mage.target.Target)6 CardsImpl (mage.cards.CardsImpl)5 UUID (java.util.UUID)3 FilterOwnedCard (mage.filter.common.FilterOwnedCard)3 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)3 ExileZone (mage.game.ExileZone)3 FilterInstantOrSorceryCard (mage.filter.common.FilterInstantOrSorceryCard)2 Permanent (mage.game.permanent.Permanent)2 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 ArrayList (java.util.ArrayList)1 Objects (java.util.Objects)1 MageObject (mage.MageObject)1