use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class GrappleWithThePastEffect 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(filter);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.chooseUse(outcome, "Return a creature or land card from your graveyard to hand?", source, game) && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class GraveyardShovelEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player controller = game.getPlayer(source.getControllerId());
if (targetPlayer == null || controller == null || targetPlayer.getGraveyard().isEmpty()) {
return false;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard();
target.setNotTarget(true);
targetPlayer.chooseTarget(Outcome.Exile, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return true;
}
targetPlayer.moveCards(card, Zone.EXILED, source, game);
if (card.isCreature(game)) {
controller.gainLife(2, game, source);
}
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class MishraArtificerProdigyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterCard filter = new FilterCard("card named " + this.cardName);
filter.add(new NamePredicate(cardName));
Card card = null;
// Graveyard
if (controller.chooseUse(Outcome.Neutral, "Search your graveyard?", source, game)) {
// You can't fail to find the card in your graveyard because it's not hidden
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter);
if (controller.choose(Outcome.PutCardInPlay, controller.getGraveyard(), target, game)) {
card = game.getCard(target.getFirstTarget());
}
}
// Hand
if (card == null && controller.chooseUse(Outcome.Neutral, "Search your hand?", source, game)) {
TargetCardInHand target = new TargetCardInHand(0, 1, filter);
if (controller.choose(Outcome.PutCardInPlay, controller.getHand(), target, game)) {
card = game.getCard(target.getFirstTarget());
}
}
// Library
if (card == null && controller.chooseUse(Outcome.Neutral, "Search your library?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
if (controller.searchLibrary(target, source, game)) {
card = game.getCard(target.getFirstTarget());
}
controller.shuffleLibrary(source, game);
}
// Put on battlefield
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 OrahSkyclaveHierophantTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent() || !zEvent.getTarget().isControlledBy(getControllerId()) || (!zEvent.getTarget().hasSubtype(SubType.CLERIC, game) && !zEvent.getTarget().getId().equals(getSourceId()))) {
return false;
}
FilterCard filterCard = new FilterCard("Cleric card with mana value less than " + (zEvent.getTarget().getManaValue()));
filterCard.add(SubType.CLERIC.getPredicate());
filterCard.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, zEvent.getTarget().getManaValue()));
this.getTargets().clear();
this.addTarget(new TargetCardInYourGraveyard(filterCard));
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class PortOfKarfellEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.millCards(4, source, game);
TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
target.setNotTarget(true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return true;
}
player.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return true;
}
Aggregations