use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class GraveEndeavorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
List<Integer> results = player.rollDice(outcome, source, game, 10, 2, 0);
int firstResult = results.get(0);
int secondResult = results.get(1);
int first, second;
if (firstResult != secondResult && player.chooseUse(outcome, "Choose a number of +1/+1 counters to put on the creature you return", "The other number will be the amount of life your opponents lose and you gain", "" + firstResult, "" + secondResult, source, game)) {
first = firstResult;
second = secondResult;
} else {
first = secondResult;
second = firstResult;
}
if (player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, game) > 0) {
TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
target.setNotTarget(true);
player.choose(outcome, target, source.getControllerId(), game);
if (target.getFirstTarget() != null) {
new ReturnFromGraveyardToBattlefieldWithCounterTargetEffect(CounterType.P1P1.createInstance(first)).setTargetPointer(new FixedTarget(target.getFirstTarget(), game)).apply(game, source);
}
}
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(playerId);
if (opponent == null) {
continue;
}
opponent.loseLife(second, game, source, false);
}
player.gainLife(second, game, source);
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class HauntingVoyageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
SubType chosenSubType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
if (controller != null && chosenSubType != null) {
Set<Card> cardsToBattlefield = new LinkedHashSet<>();
if (!ForetoldCondition.instance.apply(game, source)) {
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 2, new FilterBySubtypeCard(chosenSubType), true);
controller.chooseTarget(outcome, target, source, game);
for (UUID cardId : target.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
cardsToBattlefield.add(card);
}
}
} else {
for (UUID cardId : controller.getGraveyard()) {
Card card = game.getCard(cardId);
if (card != null && card.hasSubtype(chosenSubType, game)) {
cardsToBattlefield.add(card);
}
}
}
if (!cardsToBattlefield.isEmpty()) {
controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game);
return true;
}
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class HarnessTheStormEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) {
CastFromHandWatcher watcher = game.getState().getWatcher(CastFromHandWatcher.class);
if (watcher != null && watcher.spellWasCastFromHand(event.getSourceId())) {
Spell spell = game.getState().getStack().getSpell(event.getSourceId());
if (spell != null) {
FilterCard filterCard = new FilterCard("a card named " + spell.getName() + " in your graveyard");
filterCard.add(new NamePredicate(spell.getName()));
this.getTargets().clear();
this.getTargets().add(new TargetCardInYourGraveyard(filterCard));
return true;
}
}
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class IncarnationTechniqueEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.millCards(5, 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);
}
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class MakeAWishEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || player.getGraveyard().isEmpty()) {
return false;
}
TargetCard target = new TargetCardInYourGraveyard(Math.min(player.getGraveyard().size(), 2), StaticFilters.FILTER_CARD);
target.setNotTarget(true);
target.setRandom(true);
target.chooseTarget(outcome, player.getId(), source, game);
return player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
}
Aggregations