Search in sources :

Example 91 with Effect

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 92 with Effect

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CountersSourceCount(mage.abilities.dynamicvalue.common.CountersSourceCount) Player(mage.players.Player) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) SacrificeSourceUnlessPaysEffect(mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect)

Example 93 with Effect

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect)

Example 94 with Effect

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;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 95 with Effect

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;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) UginTheIneffableToken(mage.game.permanent.token.UginTheIneffableToken) MageObjectReference(mage.MageObjectReference) Predicates(mage.filter.predicate.Predicates) FilterPermanent(mage.filter.FilterPermanent) Player(mage.players.Player) FixedTarget(mage.target.targetpointer.FixedTarget) HashSet(java.util.HashSet) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) MageObject(mage.MageObject) Card(mage.cards.Card) mage.constants(mage.constants) FilterCard(mage.filter.FilterCard) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) Set(java.util.Set) OneShotEffect(mage.abilities.effects.OneShotEffect) CardUtil(mage.util.CardUtil) UUID(java.util.UUID) LoyaltyAbility(mage.abilities.LoyaltyAbility) CardSetInfo(mage.cards.CardSetInfo) Game(mage.game.Game) AsThoughEffectImpl(mage.abilities.effects.AsThoughEffectImpl) Effect(mage.abilities.effects.Effect) GameEvent(mage.game.events.GameEvent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) InfoEffect(mage.abilities.effects.common.InfoEffect) CardImpl(mage.cards.CardImpl) SpellsCostReductionControllerEffect(mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ColorlessPredicate(mage.filter.predicate.mageobject.ColorlessPredicate) Benefit(mage.constants.Outcome.Benefit) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) Ability(mage.abilities.Ability) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) InfoEffect(mage.abilities.effects.common.InfoEffect) SpellsCostReductionControllerEffect(mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect)

Aggregations

Effect (mage.abilities.effects.Effect)328 OneShotEffect (mage.abilities.effects.OneShotEffect)254 FixedTarget (mage.target.targetpointer.FixedTarget)224 Permanent (mage.game.permanent.Permanent)180 Player (mage.players.Player)167 UUID (java.util.UUID)75 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)60 Card (mage.cards.Card)57 MageObject (mage.MageObject)41 ContinuousEffect (mage.abilities.effects.ContinuousEffect)40 TargetPermanent (mage.target.TargetPermanent)39 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)38 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)38 FilterPermanent (mage.filter.FilterPermanent)29 ReturnToBattlefieldUnderOwnerControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)28 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)27 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)25 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)24 AttachEffect (mage.abilities.effects.common.AttachEffect)23 Target (mage.target.Target)22