use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class NorrittDelayedDestroyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
DestroyTargetEffect effect = new DestroyTargetEffect();
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance));
delayedAbility.getDuration();
delayedAbility.getTargets().addAll(source.getTargets());
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class TransmogrifyingWandEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(source.getFirstTarget());
if (creature == null) {
return false;
}
Effect effect = new CreateTokenTargetEffect(new OxToken());
effect.setTargetPointer(new FixedTarget(creature.getControllerId(), game));
new DestroyTargetEffect().apply(game, source);
return effect.apply(game, source);
}
use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class FatalLoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player chosenOpponent = game.getPlayer(targetPointer.getFirst(game, source));
if (controller != null && chosenOpponent != null) {
if (chosenOpponent.chooseUse(Outcome.Neutral, "If you choose Yes, the controller draws three cards. If no, the controller gets to destroy up to two target creatures that you control and you get to draw up to 3 cards. Those creatures can't be regenerated.", source, game)) {
controller.drawCards(3, source, game);
} else {
FilterCreaturePermanent filter = new FilterCreaturePermanent("chosen opponent's creature");
filter.add(new ControllerIdPredicate(chosenOpponent.getId()));
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 2, filter, false);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) {
Effect destroyCreature = new DestroyTargetEffect(true);
destroyCreature.setTargetPointer(new FixedTarget(targetId, game));
destroyCreature.apply(game, source);
}
Effect opponentDrawsCards = new DrawCardTargetEffect(StaticValue.get(3), false, true);
opponentDrawsCards.setTargetPointer(new FixedTarget(chosenOpponent.getId()));
opponentDrawsCards.apply(game, source);
return true;
}
}
}
return false;
}
use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class DestroyPlaneswalkerWhenDamagedTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = getSourcePermanentIfItStillExists(game);
if (permanent == null) {
return false;
}
boolean applies = filter != null ? permanent.isPlaneswalker(game) && filter.match(permanent, game) : event.getSourceId().equals(getSourceId());
if (applies) {
Effect effect = new DestroyTargetEffect();
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
this.getEffects().clear();
this.addEffect(effect);
return true;
}
return false;
}
use of mage.abilities.effects.common.DestroyTargetEffect in project mage by magefree.
the class EvilTwinPredicate method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{U}{B}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent(filter));
blueprint.getAbilities().add(ability);
return true;
}
Aggregations