use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class DeathbonnetHulkEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCard target = new TargetCardInGraveyard(0, 1);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
boolean flag = card.isCreature(game);
player.moveCards(card, Zone.EXILED, source, game);
if (!flag) {
return true;
}
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
return true;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class DanseMacabreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int toughness = 0;
Cards cards = new CardsImpl();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null || game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 1) {
continue;
}
TargetPermanent target = new TargetPermanent(filter);
target.setNotTarget(true);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
continue;
}
if (source.isControlledBy(playerId)) {
toughness += permanent.getToughness().getValue();
}
cards.add(permanent);
permanent.sacrifice(source, game);
}
int result = controller.rollDice(outcome, source, game, 20) + toughness;
cards.retainZone(Zone.GRAVEYARD, game);
if (cards.isEmpty()) {
return true;
}
FilterCard filterCard = new FilterCard("card put into a graveyard this way");
filterCard.add(Predicates.or(cards.stream().map(cardId -> new CardIdPredicate(cardId)).collect(Collectors.toSet())));
TargetCardInGraveyard target;
if (result >= 15) {
target = new TargetCardInGraveyard(0, 2, filterCard);
} else if (result > 0) {
target = new TargetCardInGraveyard(filterCard);
} else {
return true;
}
target.setNotTarget(true);
controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game);
controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game);
return true;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class DiregrafHordeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (!new ZombieDecayedToken().putOntoBattlefield(2, game, source, source.getControllerId())) {
return false;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ExileTargetEffect(), false, "exile up to two target cards from graveyards");
ability.addTarget(new TargetCardInGraveyard(0, 2));
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class DimirDoppelgangerCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DimirDoppelgangerEffect(), new ManaCostsImpl("{1}{U}{B}"));
ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
blueprint.getAbilities().add(ability);
return true;
}
Aggregations