use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class CharmbreakerDevilsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || player.getGraveyard().count(StaticFilters.FILTER_CARD_INSTANT_AND_SORCERY, game) < 1) {
return false;
}
TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_INSTANT_AND_SORCERY);
target.setRandom(true);
target.setNotTarget(true);
target.chooseTarget(outcome, player.getId(), source, game);
Card card = game.getCard(target.getFirstTarget());
return card != null && player.moveCards(card, Zone.HAND, source, game);
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class ConcoctEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.surveil(3, source, game);
Target target = new TargetCardInYourGraveyard(filter);
target.setNotTarget(true);
if (player.choose(outcome, target, source.getSourceId(), game)) {
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
effect.apply(game, source);
}
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class DarkSupplicantEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
FilterCard filter = new FilterCard("card named Scion of Darkness");
filter.add(new NamePredicate("Scion of Darkness"));
if (controller == null) {
return false;
}
Card selectedCard = null;
// Graveyard check
if (controller.chooseUse(Outcome.Benefit, "Search your graveyard for Scion of Darkness?", source, game)) {
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter, true);
if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
selectedCard = game.getCard(target.getFirstTarget());
}
}
// Hand check
if (selectedCard == null && controller.chooseUse(Outcome.Benefit, "Search your hand for Scion of Darkness?", source, game)) {
TargetCardInHand target = new TargetCardInHand(0, 1, filter);
if (controller.choose(Outcome.PutCardInPlay, controller.getHand(), target, game)) {
if (!target.getTargets().isEmpty()) {
selectedCard = game.getCard(target.getFirstTarget());
}
}
}
// Library check
boolean librarySearched = false;
if (selectedCard == null && controller.chooseUse(Outcome.Benefit, "Search your library for Scion of Darkness?", source, game)) {
librarySearched = true;
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
selectedCard = game.getCard(target.getFirstTarget());
}
}
}
if (selectedCard != null) {
controller.moveCards(selectedCard, Zone.BATTLEFIELD, source, game);
}
if (librarySearched) {
controller.shuffleLibrary(source, game);
}
return true;
}
Aggregations