use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class GravePerilEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
if (permanent != null) {
if (permanent.sacrifice(source, game)) {
Effect effect = new DestroyTargetEffect();
effect.setTargetPointer(this.getTargetPointer());
return effect.apply(game, source);
}
}
return false;
}
use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class ZagrasThiefOfHeartbeatsTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!((DamagedEvent) event).isCombatDamage()) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (permanent == null || !permanent.isCreature(game) || !permanent.isControlledBy(getControllerId())) {
return false;
}
Permanent damaged = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (damaged == null || !permanent.isPlaneswalker(game)) {
return false;
}
this.getEffects().clear();
this.addEffect(new DestroyTargetEffect().setTargetPointer(new FixedTarget(event.getTargetId(), game)));
return true;
}
use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class BlindZealotTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creature or planeswalker" + opponent.getLogName() + " controls");
filter.add(new ControllerIdPredicate(opponent.getId()));
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DestroyTargetEffect(), false, "destroy target creature or planeswalker that player controls");
this.getEffects().clear();
this.addEffect(new DoWhenCostPaid(ability, new DiscardTargetCost(new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE)), "Discard a creature card?"));
return true;
}
use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class FinaleOfEternityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
new DestroyTargetEffect(false, true).apply(game, source);
if (source.getManaCostsToPay().getX() < 10) {
return true;
}
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
return player.moveCards(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game), Zone.BATTLEFIELD, source, game);
}
use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class ChainOfAcidEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID targetId = source.getFirstTarget();
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
Player affectedPlayer = game.getPlayer(permanent.getControllerId());
if (affectedPlayer != null) {
Effect effect = new DestroyTargetEffect();
effect.setTargetPointer(new FixedTarget(targetId, game));
effect.apply(game, source);
if (affectedPlayer.chooseUse(Outcome.Copy, "Copy the spell?", source, game)) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
spell.createCopyOnStack(game, source, affectedPlayer.getId(), true);
}
}
return true;
}
}
}
return false;
}
Aggregations