use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class RecallEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
// Discard X cards
Cards cardsDiscarded = controller.discard(source.getManaCostsToPay().getX(), false, false, source, game);
if (!cardsDiscarded.isEmpty()) {
// then return a card from your graveyard to your hand for each card discarded this way
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(cardsDiscarded.size(), new FilterCard());
target.setNotTarget(true);
target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game);
controller.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class SoulshiftAbility method trigger.
@Override
public void trigger(Game game, UUID controllerId, GameEvent triggeringEvent) {
this.getTargets().clear();
int intValue = amount.calculate(game, this, null);
FilterCard filter = new FilterCard("Spirit card with mana value " + intValue + " or less from your graveyard");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, intValue + 1));
filter.add(SubType.SPIRIT.getPredicate());
this.addTarget(new TargetCardInYourGraveyard(filter));
// To change body of generated methods, choose Tools | Templates.
super.trigger(game, controllerId, triggeringEvent);
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class FallOfTheThranReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Map<UUID, Set<Card>> toBattlefield = new LinkedHashMap<>();
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(2, 2, StaticFilters.FILTER_CARD_LAND);
target.setNotTarget(true);
target.setTargetController(playerId);
if (target.canChoose(source.getSourceId(), playerId, game)) {
player.choose(outcome, target, source.getSourceId(), game);
if (target.getTargets().size() == 2) {
toBattlefield.put(playerId, new CardsImpl(target.getTargets()).getCards(game));
}
}
}
}
for (Map.Entry<UUID, Set<Card>> entry : toBattlefield.entrySet()) {
Player player = game.getPlayer(entry.getKey());
if (player != null) {
player.moveCards(entry.getValue(), Zone.BATTLEFIELD, source, game);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class GraveBirthingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (opponent != null) {
Target target = new TargetCardInYourGraveyard();
target.setNotTarget(true);
opponent.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
opponent.moveCards(card, Zone.EXILED, source, game);
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class GraveConsequencesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Player> players = game.getState().getPlayersInRange(source.getControllerId(), game).stream().map(game::getPlayer).filter(Objects::nonNull).collect(Collectors.toList());
for (Player player : players) {
TargetCard target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
Cards cards = new CardsImpl(target.getTargets());
if (!cards.isEmpty()) {
player.moveCards(cards, Zone.EXILED, source, game);
}
}
for (Player player : players) {
if (!player.getGraveyard().isEmpty()) {
player.loseLife(player.getLife(), game, source, false);
}
}
return true;
}
Aggregations