use of mage.abilities.effects.Effect in project mage by magefree.
the class NemesisTrapEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && targetedCreature != null) {
// exile target
controller.moveCards(targetedCreature, Zone.EXILED, source, game);
// create token
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
effect.setTargetPointer(new FixedTarget(targetedCreature, game));
effect.apply(game, source);
for (Permanent addedToken : effect.getAddedPermanents()) {
Effect exileEffect = new ExileTargetEffect("Exile " + addedToken.getName() + " at the beginning of the next end step");
exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class PhantasmalSphereToken method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetOpponent = game.getPlayer(source.getFirstTarget());
if (controller != null && targetOpponent != null) {
Effect effect = new CreateTokenTargetEffect(new PhantasmalSphereToken(new CountersSourceCount(CounterType.P1P1).calculate(game, source, null)));
effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect.apply(game, source);
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class SentinelOfThePearlTridentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
int zcc = permanent.getZoneChangeCounter(game);
controller.moveCards(permanent, Zone.EXILED, source, game);
// create delayed triggered ability
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
effect.setTargetPointer(new FixedTarget(permanent.getId(), zcc + 1));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class TephradermSpellDamageTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getTargetId().equals(this.getSourceId())) {
return false;
}
Permanent sourcePermanent = game.getPermanent(event.getSourceId());
if (sourcePermanent != null && FILTER_CREATURE.match(sourcePermanent, getSourceId(), getControllerId(), game)) {
for (Effect effect : getEffects()) {
if (effect instanceof DamageTargetEffect) {
effect.setTargetPointer(new FixedTarget(sourcePermanent.getId(), game));
((DamageTargetEffect) effect).setAmount(StaticValue.get(event.getAmount()));
}
}
return true;
}
return false;
}
use of mage.abilities.effects.Effect in project mage by magefree.
the class UginTheIneffableLookAtFaceDownEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = ((ZoneChangeEvent) event);
if (zEvent.getToZone() == Zone.BATTLEFIELD || tokenRefs.stream().noneMatch(tokenRef -> tokenRef.refersTo(zEvent.getTarget(), game))) {
return false;
}
this.getEffects().clear();
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(cardRef));
this.addEffect(effect);
return true;
}
Aggregations