use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class ZarethSanTheTricksterTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent == null || !event.getSourceId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
FilterCard filter = new FilterPermanentCard("permanent card in " + opponent.getLogName() + "'s graveyard");
filter.add(new OwnerIdPredicate(opponent.getId()));
this.getTargets().clear();
this.addTarget(new TargetCardInGraveyard(filter));
return true;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class CemeteryDesecratorRemoveCountersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
target.setNotTarget(true);
controller.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
int manaValue = card.getManaValue();
if (controller.moveCards(card, Zone.EXILED, source, game)) {
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new CemeteryDesecratorRemoveCountersEffect(manaValue), false, triggerText);
ability.addTarget(new TargetPermanent());
Mode mode = new Mode(new BoostTargetEffect(-manaValue, -manaValue, Duration.EndOfTurn).setText("Target creature an opponent controls gets -X/-X until end of turn, where X is the mana value of the exiled card"));
mode.addTarget(new TargetOpponentsCreaturePermanent());
ability.addMode(mode);
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
}
}
return false;
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class CemeteryProtectorTriggeredAbility 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 DakkonShadowSlayerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
boolean inGrave = player.getGraveyard().count(StaticFilters.FILTER_CARD_ARTIFACT, game) > 0;
if (!inGrave && player.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game) < 1) {
return false;
}
TargetCard target;
if (!inGrave || player.chooseUse(outcome, "Choose a card in your hand or your graveyard?", null, "Hand", "Graveyard", source, game)) {
target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_ARTIFACT);
player.choose(outcome, player.getHand(), target, game);
} else {
target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_ARTIFACT);
player.choose(outcome, player.getGraveyard(), target, game);
}
Card card = game.getCard(target.getFirstTarget());
return card != null && player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
use of mage.target.common.TargetCardInGraveyard in project mage by magefree.
the class EntrailsFeasterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && source.getSourceId() != null) {
Permanent sourceObject = (Permanent) source.getSourceObjectIfItStillExists(game);
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseUse(outcome, "Exile a creature card from a graveyard?", source, game)) {
if (controller.choose(Outcome.Exile, target, source.getId(), game)) {
Card cardChosen = game.getCard(target.getFirstTarget());
if (cardChosen != null) {
controller.moveCardsToExile(cardChosen, source, game, true, null, "");
if (sourceObject != null) {
sourceObject.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers(controller.getLogName() + " puts a +1/+1 counter on " + sourceObject.getLogName());
}
}
} else if (sourceObject != null) {
sourceObject.tap(source, game);
}
} else if (sourceObject != null) {
sourceObject.tap(source, game);
}
return true;
}
return false;
}
Aggregations