Search in sources :

Example 81 with TargetCard

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

the class EccentricFarmerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.millCards(3, source, game);
    if (player.getGraveyard().count(StaticFilters.FILTER_CARD_LAND, game) < 1) {
        return true;
    }
    TargetCard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_LAND, true);
    player.choose(outcome, target, source.getSourceId(), game);
    player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 82 with TargetCard

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

the class ExperimentalOverloadEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int spellCount = player.getGraveyard().count(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, game);
    new WeirdToken2(spellCount).putOntoBattlefield(1, game, source, source.getControllerId());
    if (spellCount < 1) {
        return true;
    }
    TargetCard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, true);
    player.choose(outcome, player.getGraveyard(), target, game);
    return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) WeirdToken2(mage.game.permanent.token.WeirdToken2) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Example 83 with TargetCard

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

the class ExtortionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    Player you = game.getPlayer(source.getControllerId());
    if (targetPlayer == null || you == null) {
        return false;
    }
    you.lookAtCards("Discard", targetPlayer.getHand(), game);
    TargetCard target = new TargetCardInHand(0, 2, StaticFilters.FILTER_CARD_CARDS);
    target.setNotTarget(true);
    you.choose(Outcome.Discard, targetPlayer.getHand(), target, game);
    targetPlayer.discard(new CardsImpl(target.getTargets()), false, source, game);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCard(mage.target.TargetCard) CardsImpl(mage.cards.CardsImpl)

Example 84 with TargetCard

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

the class GontiLordOfLuxuryLookEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    MageObject sourceObject = source.getSourceObject(game);
    if (controller == null || opponent == null || sourceObject == null) {
        return false;
    }
    Cards topCards = new CardsImpl();
    topCards.addAll(opponent.getLibrary().getTopCards(game, 4));
    TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to exile"));
    controller.choose(outcome, topCards, target, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        controller.putCardsOnBottomOfLibrary(topCards, game, source, false);
        return true;
    }
    topCards.remove(card);
    // move card to exile
    UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    card.setFaceDown(true, game);
    if (controller.moveCardsToExile(card, source, game, false, exileZoneId, sourceObject.getIdName())) {
        card.setFaceDown(true, game);
        Set<UUID> exileZones = (Set<UUID>) game.getState().getValue(VALUE_PREFIX + source.getSourceId().toString());
        if (exileZones == null) {
            exileZones = new HashSet<>();
            game.getState().setValue(VALUE_PREFIX + source.getSourceId().toString(), exileZones);
        }
        exileZones.add(exileZoneId);
        // allow to cast the card
        ContinuousEffect effect = new GontiLordOfLuxuryCastFromExileEffect();
        effect.setTargetPointer(new FixedTarget(card.getId(), game));
        game.addEffect(effect, source);
        // and you may spend mana as though it were mana of any color to cast it
        effect = new GontiLordOfLuxurySpendAnyManaEffect();
        effect.setTargetPointer(new FixedTarget(card.getId(), game));
        game.addEffect(effect, source);
        // For as long as that card remains exiled, you may look at it
        effect = new GontiLordOfLuxuryLookEffect(controller.getId());
        effect.setTargetPointer(new FixedTarget(card.getId(), game));
        game.addEffect(effect, source);
    }
    // then put the rest on the bottom of that library in a random order
    controller.putCardsOnBottomOfLibrary(topCards, game, source, false);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Set(java.util.Set) HashSet(java.util.HashSet) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) FilterCard(mage.filter.FilterCard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 85 with TargetCard

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

the class HaraldUnitesTheElvesTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.millCards(3, source, game);
    TargetCard targetCard = new TargetCardInYourGraveyard(0, 1, filter, true);
    player.choose(outcome, targetCard, source.getSourceId(), game);
    Card card = player.getGraveyard().get(targetCard.getFirstTarget(), game);
    if (card != null) {
        player.moveCards(card, Zone.BATTLEFIELD, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterCard(mage.filter.FilterCard) 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