use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class ImmortalCoilPreventionEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
if (game.replaceEvent(new PreventDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), event.getAmount(), ((DamageEvent) event).isCombatDamage()))) {
return false;
}
int damage = event.getAmount();
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(Math.min(damage, player.getGraveyard().size()), StaticFilters.FILTER_CARD);
target.setNotTarget(true);
player.choose(outcome, target, source.getSourceId(), game);
player.moveCards(new CardsImpl(target.getTargets()), Zone.EXILED, source, game);
}
event.setAmount(0);
game.fireEvent(new PreventedDamageEvent(event.getTargetId(), source.getSourceId(), source, source.getControllerId(), damage));
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class MissionBriefingReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.surveil(2, source, game);
Target target = new TargetCardInYourGraveyard(new FilterInstantOrSorceryCard("instant or sorcery card from your graveyard"));
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return true;
}
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect();
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
effect = new MissionBriefingReplacementEffect(card.getId());
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class NefariousLichLifeGainReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(event.getPlayerId());
if (controller != null) {
Target target = new TargetCardInYourGraveyard(amount, new FilterCard("card in your graveyard"));
if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
if (controller.choose(Outcome.Exile, target, source.getSourceId(), game)) {
Set<Card> cards = new HashSet<>(amount);
for (UUID targetId : target.getTargets()) {
Card card = controller.getGraveyard().get(targetId, game);
if (card != null) {
cards.add(card);
}
}
controller.moveCardsToExile(cards, source, game, true, null, "");
return true;
}
}
controller.lost(game);
}
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class SwiftWarkiteEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.chooseUse(Outcome.PutCardInPlay, "Put a creature card from your hand? (No = from your graveyard)", source, game)) {
Target target = new TargetCardInHand(0, 1, filter);
controller.choose(outcome, target, source.getSourceId(), game);
Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
game.addEffect(effect, source);
Effect effect2 = new ReturnToHandTargetEffect();
effect2.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect2);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
} else {
Target target = new TargetCardInYourGraveyard(0, 1, filter);
target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game);
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
game.addEffect(effect, source);
Effect effect2 = new ReturnToHandTargetEffect();
effect2.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect2);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class VenerableWarsingerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if (player == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
FilterCard filter = new FilterCreatureCard("creature card with mana value " + event.getAmount() + " less from your graveyard");
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, event.getAmount() + 1));
this.getTargets().clear();
this.addTarget(new TargetCardInYourGraveyard(filter));
return true;
}
Aggregations