use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class ForbiddenCryptPutIntoYourGraveyardReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
boolean cardReturned = false;
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard();
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
if (target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cardReturned = true;
}
}
}
if (!cardReturned) {
game.informPlayers(controller.getLogName() + " can't return a card from graveyard to hand.");
controller.lost(game);
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class GrimCaptainsCallEffect method returnToHand.
private void returnToHand(Game game, SubType subType, Player controller, Ability source) {
FilterCreatureCard filter = new FilterCreatureCard(subType.getDescription() + " card");
filter.add(subType.getPredicate());
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard(filter));
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
if (controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
}
}
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class InfernalOfferingReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetOpponent(true);
target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), game);
Player opponent = game.getPlayer(target.getFirstTarget());
target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), game)) {
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
if (opponent != null) {
target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), game)) {
Card card = opponent.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class MantleOfTheAncientsPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = source.getSourcePermanentOrLKI(game);
if (player == null || sourcePermanent == null) {
return false;
}
Permanent permanent = game.getPermanent(sourcePermanent.getAttachedTo());
if (permanent == null) {
return false;
}
FilterCard filter = new FilterCard("Aura or Equipment card that can be attached to " + permanent.getName());
filter.add(new MantleOfTheAncientsPredicate(permanent));
TargetCard target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter, true);
player.choose(outcome, target, source.getSourceId(), game);
Cards cards = new CardsImpl(target.getTargets());
if (cards.isEmpty()) {
return false;
}
cards.getCards(game).stream().forEach(card -> game.getState().setValue("attachTo:" + card.getId(), permanent));
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
for (UUID cardId : cards) {
permanent.addAttachment(cardId, source, game);
}
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class RelentlessDeadEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.chooseUse(Outcome.Benefit, "Do you want to pay {X} to return zombie?", source, game)) {
int payCount = ManaUtil.playerPaysXGenericMana(true, "Relentless Dead", controller, source, game);
// can be 0
FilterCard filter = new FilterCard("Another target Zombie card with mana value {" + payCount + "}");
filter.add(SubType.ZOMBIE.getPredicate());
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, payCount));
filter.add(new AnotherCardPredicate());
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
if (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;
}
Aggregations