use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class GravestormEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null && you != null) {
FilterCard filter = new FilterCard("card from your graveyard");
filter.add(new OwnerIdPredicate(targetPlayer.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
boolean opponentChoosesExile = targetPlayer.chooseUse(Outcome.Exile, "Exile a card from your graveyard?", source, game);
boolean opponentExilesACard = false;
if (opponentChoosesExile && targetPlayer.chooseTarget(Outcome.Exile, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
opponentExilesACard = targetPlayer.moveCardToExileWithInfo(card, null, "", source, game, Zone.GRAVEYARD, true);
}
}
if (!opponentExilesACard) {
if (you.chooseUse(Outcome.DrawCard, "Draw a card?", source, game)) {
you.drawCards(1, source, game);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class KairiTheSwirlingSkyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.millCards(6, source, game);
TargetCard target = new TargetCardInGraveyard(0, 2, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY);
target.setNotTarget(true);
player.choose(outcome, player.getGraveyard(), target, game);
return player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class MausoleumTurnkeyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID opponentId = null;
if (game.getOpponents(controller.getId()).size() > 1) {
Target target = new TargetOpponent(true);
if (controller.chooseTarget(outcome, target, source, game)) {
opponentId = target.getFirstTarget();
}
} else {
opponentId = game.getOpponents(controller.getId()).iterator().next();
}
if (opponentId != null) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
FilterCreatureCard filter = new FilterCreatureCard("creature card from " + controller.getLogName() + " graveyard");
filter.add(new OwnerIdPredicate(controller.getId()));
Target target = new TargetCardInGraveyard(filter);
opponent.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class ForgottenLoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if (you != null && opponent != null) {
FilterCard filter = new FilterCard();
filter.add(new OwnerIdPredicate(you.getId()));
Cost cost = new ManaCostsImpl("{G}");
TargetCardInGraveyard chosenCard;
Card card = null;
boolean done = false;
do {
chosenCard = new TargetCardInGraveyard(filter);
chosenCard.setNotTarget(true);
if (chosenCard.canChoose(source.getSourceId(), opponent.getId(), game)) {
opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game);
card = game.getCard(chosenCard.getFirstTarget());
if (card != null) {
filter.add(Predicates.not(new CardIdPredicate(card.getId())));
game.informPlayers("Forgotten Lore: " + opponent.getLogName() + " has chosen " + card.getLogName());
}
} else {
done = true;
}
if (!done) {
if (cost.canPay(source, source, you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {G} to choose a different card ?", source, game)) {
cost.clearPaid();
if (!cost.pay(source, game, source, you.getId(), false, null)) {
done = true;
}
} else {
done = true;
}
}
} while (!done);
if (card != null) {
Cards cardsToHand = new CardsImpl();
cardsToHand.add(card);
you.moveCards(cardsToHand, Zone.HAND, source, game);
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class InkEyesServantOfOniTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(this.sourceId) || !((DamagedPlayerEvent) event).isCombatDamage()) {
return false;
}
Player damagedPlayer = game.getPlayer(event.getTargetId());
if (damagedPlayer == null) {
return false;
}
FilterCard filter = new FilterCard("creature in " + damagedPlayer.getName() + "'s graveyard");
filter.add(CardType.CREATURE.getPredicate());
filter.add(new OwnerIdPredicate(damagedPlayer.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
this.getTargets().clear();
this.addTarget(target);
return true;
}
Aggregations