use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class KayaTheInexorableEmblemEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Choice zoneChoice = new ChoiceImpl(true);
zoneChoice.setMessage("Cast a legendary spell from hand, graveyard, or exile");
zoneChoice.setChoices(choices);
zoneChoice.clearChoice();
if (player.choose(Outcome.PlayForFree, zoneChoice, game)) {
TargetCard target = null;
switch(zoneChoice.getChoice()) {
case "Hand":
target = new TargetCardInHand(0, 1, filter);
target.setTargetName("legendary spell from your hand");
break;
case "Graveyard":
target = new TargetCardInYourGraveyard(0, 1, filter, true);
target.setTargetName("legendary spell from your graveyard");
break;
case "Exile":
target = new TargetCardInExile(0, 1, filter, null, true);
target.setNotTarget(true);
target.setTargetName("legendary spell you own in exile");
break;
}
if (target != null && player.chooseTarget(Outcome.PlayForFree, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
boolean cardWasCast = player.cast(player.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
return cardWasCast;
}
}
}
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class AraumiOfTheDeadTideCost method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player player = game.getPlayer(controllerId);
if (player == null) {
return paid;
}
int oppCount = game.getOpponents(controllerId).size();
TargetCard target = new TargetCardInYourGraveyard(oppCount, StaticFilters.FILTER_CARD);
target.setNotTarget(true);
player.choose(Outcome.Exile, target, source.getSourceId(), game);
Cards cards = new CardsImpl(target.getTargets());
if (cards.size() < oppCount) {
return paid;
}
player.moveCards(cards, Zone.EXILED, ability, game);
paid = cards.stream().map(game.getState()::getZone).filter(Zone.EXILED::equals).count() >= oppCount;
return paid;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class BloodOnTheSnowEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int snow = ManaPaidSourceWatcher.getSnowPaid(source.getId(), game);
FilterCard filter = new FilterCard("a creature or planeswalker card with mana value " + snow + " or less from your graveyard");
filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.PLANESWALKER.getPredicate()));
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, snow + 1));
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter, true);
controller.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
return true;
}
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class CruelUltimatumEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
return controller.moveCards(card, Zone.HAND, source, game);
}
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class BondOfInsightEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
player.millCards(4, source, game);
}
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCard target = new TargetCardInYourGraveyard(0, 2, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, true);
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Cards cards = new CardsImpl(target.getTargets());
return player.moveCards(cards, Zone.HAND, source, game);
}
Aggregations