Search in sources :

Example 41 with TargetCardInHand

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

the class MinnWilyIllusionistEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = (Permanent) getValue("creatureDied");
    if (player == null || permanent == null) {
        return false;
    }
    FilterCard filterCard = new FilterPermanentCard("permanent card with mana value " + permanent.getPower().getValue() + " or less");
    filterCard.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, permanent.getPower().getValue() + 1));
    TargetCardInHand target = new TargetCardInHand(0, 1, filterCard);
    player.choose(Outcome.PutCardInPlay, player.getHand(), target, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        return false;
    }
    return player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterPermanentCard(mage.filter.common.FilterPermanentCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetCardInHand(mage.target.common.TargetCardInHand) FilterCard(mage.filter.FilterCard) FilterPermanentCard(mage.filter.common.FilterPermanentCard) Card(mage.cards.Card)

Example 42 with TargetCardInHand

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

the class MindWarpEffect 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;
    }
    int amountToDiscard = source.getManaCostsToPay().getX();
    TargetCard target = new TargetCardInHand(amountToDiscard, StaticFilters.FILTER_CARD_CARDS);
    you.choose(outcome, 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 43 with TargetCardInHand

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

the class PhosphorescentFeastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int chroma = 0;
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    if (player.getHand().count(new FilterCard(), game) > 0) {
        TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCard());
        if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
            Cards cards = new CardsImpl();
            for (UUID uuid : target.getTargets()) {
                cards.add(player.getHand().get(uuid, game));
            }
            player.revealCards("cards", cards, game);
            for (Card card : cards.getCards(game)) {
                chroma += card.getManaCost().getMana().getGreen();
            }
            player.gainLife(chroma * 2, game, source);
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard)

Example 44 with TargetCardInHand

use of mage.target.common.TargetCardInHand 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 45 with TargetCardInHand

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

the class SelvalasStampedeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    // Outcome.Detriment - AI will use library will the time (Free choice)
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    TwoChoiceVote vote = new TwoChoiceVote("Wild (from library to battlefield)", "Free (from hand to battlefield)", Outcome.Detriment);
    vote.doVotes(source, game);
    int wildCount = vote.getVoteCount(true);
    int freeCount = vote.getVoteCount(false);
    // Reveal cards from the top of your library until you reveal a creature card for each wild vote.
    // Put those creature cards onto the battlefield, then shuffle the rest into your library.
    Cards toReveal = new CardsImpl();
    Cards creatureCards = new CardsImpl();
    for (Card card : player.getLibrary().getCards(game)) {
        if (creatureCards.size() >= wildCount) {
            break;
        }
        if (card.isCreature(game)) {
            creatureCards.add(card);
        }
        toReveal.add(card);
    }
    if (toReveal.size() > 0) {
        player.revealCards(source, toReveal, game);
    }
    if (creatureCards.size() > 0) {
        player.moveCards(creatureCards, Zone.BATTLEFIELD, source, game);
    }
    player.shuffleLibrary(source, game);
    // You may put a permanent card from your hand onto the battlefield for each free vote
    if (freeCount > 0) {
        TargetCardInHand target = new TargetCardInHand(0, freeCount, StaticFilters.FILTER_CARD_PERMANENT);
        player.choose(Outcome.PutCreatureInPlay, player.getHand(), target, game);
        creatureCards.clear();
        creatureCards.addAll(target.getTargets());
        player.moveCards(creatureCards, Zone.BATTLEFIELD, source, game);
    }
    return wildCount + freeCount > 0;
}
Also used : Player(mage.players.Player) TargetCardInHand(mage.target.common.TargetCardInHand) TwoChoiceVote(mage.choices.TwoChoiceVote)

Aggregations

TargetCardInHand (mage.target.common.TargetCardInHand)148 Player (mage.players.Player)133 Card (mage.cards.Card)96 FilterCard (mage.filter.FilterCard)61 Permanent (mage.game.permanent.Permanent)45 CardsImpl (mage.cards.CardsImpl)41 UUID (java.util.UUID)39 Cards (mage.cards.Cards)24 Target (mage.target.Target)21 TargetCard (mage.target.TargetCard)21 MageObject (mage.MageObject)17 FixedTarget (mage.target.targetpointer.FixedTarget)14 ApprovingObject (mage.ApprovingObject)13 FilterCreatureCard (mage.filter.common.FilterCreatureCard)12 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)10 RevealTargetFromHandCost (mage.abilities.costs.common.RevealTargetFromHandCost)10 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)10 ContinuousEffect (mage.abilities.effects.ContinuousEffect)9 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)9 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)9