Search in sources :

Example 91 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class PhyrexianGrimoireEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (controller != null && opponent != null) {
        if (!controller.getGraveyard().isEmpty()) {
            Cards cards = new CardsImpl();
            UUID card1 = null;
            UUID card2 = null;
            for (UUID cardId : controller.getGraveyard()) {
                card2 = card1;
                card1 = cardId;
            }
            if (card1 != null) {
                cards.add(card1);
            }
            if (card2 != null) {
                cards.add(card2);
            }
            TargetCard target = new TargetCard(Zone.GRAVEYARD, new FilterCard());
            target.setRequired(true);
            if (opponent.choose(Outcome.Exile, cards, target, game)) {
                Card card = game.getCard(target.getFirstTarget());
                cards.remove(target.getFirstTarget());
                if (card != null) {
                    controller.moveCards(card, Zone.EXILED, source, game);
                }
                if (!cards.isEmpty()) {
                    card = game.getCard(cards.iterator().next());
                    if (card != null) {
                        controller.moveCards(card, Zone.HAND, source, game);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 92 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class RevealingEyeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(source.getFirstTarget());
    if (controller == null || opponent == null) {
        return false;
    }
    opponent.revealCards(source, opponent.getHand(), game);
    if (opponent.getHand().count(StaticFilters.FILTER_CARD_NON_LAND, game) < 1) {
        return true;
    }
    TargetCard target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_NON_LAND);
    controller.choose(outcome, opponent.getHand(), target, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return true;
    }
    opponent.discard(card, false, source, game);
    opponent.drawCards(1, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCard(mage.target.TargetCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 93 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class SaheelisDirectiveEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
    if (!cards.isEmpty()) {
        controller.revealCards(source, cards, game);
        FilterCard filter = new FilterArtifactCard("artifact cards with mana value " + xValue + " or less to put onto the battlefield");
        filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, xValue + 1));
        TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
        target1.setNotTarget(true);
        controller.choose(Outcome.PutCardInPlay, cards, target1, game);
        Cards toBattlefield = new CardsImpl(target1.getTargets());
        cards.removeAll(toBattlefield);
        controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
        controller.moveCards(cards, Zone.GRAVEYARD, source, game);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) TargetCard(mage.target.TargetCard) FilterArtifactCard(mage.filter.common.FilterArtifactCard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 94 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class StreamOfThoughtEffect 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(0, 4);
    target.setNotTarget(true);
    if (!player.choose(outcome, player.getGraveyard(), target, game)) {
        return false;
    }
    Cards cards = new CardsImpl(target.getTargets());
    player.putCardsOnTopOfLibrary(cards, game, source, false);
    player.shuffleLibrary(source, game);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 95 with TargetCard

use of mage.target.TargetCard in project mage by magefree.

the class StrefanMaurerProgenitorPlayVampireEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetCard target = new TargetCardInHand(0, 1, vampireCardFilter);
    if (!player.choose(outcome, player.getHand(), target, game)) {
        return false;
    }
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return false;
    }
    player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return false;
    }
    game.getCombat().addAttackingCreature(permanent.getId(), game);
    // Gains indestructable until end of turn
    ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(permanent.getId(), game));
    game.addEffect(effect, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) TargetCardInHand(mage.target.common.TargetCardInHand) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) TargetCard(mage.target.TargetCard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Aggregations

TargetCard (mage.target.TargetCard)309 Player (mage.players.Player)297 FilterCard (mage.filter.FilterCard)177 Card (mage.cards.Card)130 CardsImpl (mage.cards.CardsImpl)96 UUID (java.util.UUID)83 Cards (mage.cards.Cards)81 MageObject (mage.MageObject)80 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)52 Permanent (mage.game.permanent.Permanent)49 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)30 ApprovingObject (mage.ApprovingObject)26 TargetPlayer (mage.target.TargetPlayer)25 FilterCreatureCard (mage.filter.common.FilterCreatureCard)22 TargetOpponent (mage.target.common.TargetOpponent)22 TargetCardInHand (mage.target.common.TargetCardInHand)21 Target (mage.target.Target)19 FilterNonlandCard (mage.filter.common.FilterNonlandCard)18 FixedTarget (mage.target.targetpointer.FixedTarget)18 ArrayList (java.util.ArrayList)16