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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations