use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class TheMimeoplasmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) {
if (new CardsInAllGraveyardsCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this) >= 2) {
if (controller.chooseUse(Outcome.Benefit, "Do you want to exile two creature cards from graveyards?", source, game)) {
TargetCardInGraveyard targetCopy = new TargetCardInGraveyard(new FilterCreatureCard("creature card to become a copy of"));
targetCopy.setNotTarget(true);
if (controller.choose(Outcome.Copy, targetCopy, source.getSourceId(), game)) {
Card cardToCopy = game.getCard(targetCopy.getFirstTarget());
if (cardToCopy != null) {
FilterCreatureCard filter = new FilterCreatureCard("creature card to determine amount of additional +1/+1 counters");
filter.add(Predicates.not(new CardIdPredicate(cardToCopy.getId())));
TargetCardInGraveyard targetCounters = new TargetCardInGraveyard(filter);
targetCounters.setNotTarget(true);
if (controller.choose(Outcome.Copy, targetCounters, source.getSourceId(), game)) {
Card cardForCounters = game.getCard(targetCounters.getFirstTarget());
if (cardForCounters != null) {
Cards cardsToExile = new CardsImpl();
cardsToExile.add(cardToCopy);
cardsToExile.add(cardForCounters);
controller.moveCards(cardsToExile, Zone.EXILED, source, game);
CopyEffect copyEffect = new CopyEffect(Duration.Custom, cardToCopy, source.getSourceId());
game.addEffect(copyEffect, source);
permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), source.getControllerId(), source, game);
}
}
}
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class EnteringReturnFromGraveyardToBattlefieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetCardInGraveyard(StaticFilters.FILTER_CARD_CREATURE);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card.getId(), game));
game.addEffect(effect, source);
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class CreepingInnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (player != null && permanent != null) {
UUID exileId = CardUtil.getExileZoneId(game, source);
TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
if (player.choose(Outcome.Exile, target, source.getId(), game)) {
Card cardChosen = game.getCard(target.getFirstTarget());
if (cardChosen != null) {
int lifeAmount = 0;
player.moveCardsToExile(cardChosen, source, game, true, exileId, permanent.getName());
ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null) {
for (UUID cardId : exile) {
lifeAmount++;
}
}
for (UUID playerId : game.getOpponents(source.getControllerId())) {
game.getPlayer(playerId).loseLife(lifeAmount, game, source, false);
}
player.gainLife(lifeAmount, game, source);
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class CemeteryGatekeeperTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCardInGraveyard target = new TargetCardInGraveyard();
target.setNotTarget(true);
controller.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
MageObject sourceObject = source.getSourceObject(game);
String exileName = sourceObject == null ? null : sourceObject.getIdName();
return controller.moveCardsToExile(card, source, game, true, exileId, exileName);
}
}
return false;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class CemeteryIlluminatorWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCardInGraveyard target = new TargetCardInGraveyard();
target.setNotTarget(true);
controller.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
MageObject sourceObject = source.getSourceObject(game);
String exileName = sourceObject == null ? null : sourceObject.getIdName();
return controller.moveCardsToExile(card, source, game, true, exileId, exileName);
}
}
return false;
}
Aggregations