Search in sources :

Example 11 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class AwakenElementalToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID targetId = null;
    for (Target target : source.getTargets()) {
        targetId = target.getFirstTarget();
    }
    if (targetId != null) {
        FixedTarget fixedTarget = new FixedTarget(targetId, game);
        ContinuousEffect continuousEffect = new BecomesCreatureTargetEffect(new AwakenElementalToken(), false, true, Duration.EndOfGame);
        continuousEffect.setTargetPointer(fixedTarget);
        game.addEffect(continuousEffect, source);
        Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(3));
        effect.setTargetPointer(fixedTarget);
        return effect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) BecomesCreatureTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTargetEffect) Effect(mage.abilities.effects.Effect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 12 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class NullstoneGargoyleTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Spell spell = game.getSpell(event.getTargetId());
    if (spell.isCreature(game)) {
        return false;
    }
    SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
    if (watcher != null && watcher.getNumberOfNonCreatureSpells() == 1) {
        for (Effect effect : getEffects()) {
            effect.setTargetPointer(new FixedTarget(event.getTargetId()));
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SpellsCastWatcher(mage.watchers.common.SpellsCastWatcher) CounterTargetEffect(mage.abilities.effects.common.CounterTargetEffect) Effect(mage.abilities.effects.Effect) Spell(mage.game.stack.Spell)

Example 13 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class NoosegrafMobEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
        permanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
        Effect effect = new CreateTokenEffect(new ZombieToken());
        return effect.apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 14 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class PsychicPurgeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (getSourceId().equals(event.getTargetId())) {
        StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
        if (stackObject != null) {
            if (game.getOpponents(this.getControllerId()).contains(stackObject.getControllerId())) {
                Effect effect = this.getEffects().get(0);
                effect.setTargetPointer(new FixedTarget(stackObject.getControllerId()));
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) StackObject(mage.game.stack.StackObject) LoseLifeTargetEffect(mage.abilities.effects.common.LoseLifeTargetEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 15 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class RescueFromTheUnderworldReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    DelayedTriggeredAbility delayedAbility = ability.copy();
    delayedAbility.getTargets().addAll(source.getTargets());
    for (Effect effect : delayedAbility.getEffects()) {
        effect.getTargetPointer().init(game, source);
    }
    // add the sacrificed creature as target
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
            TargetCardInGraveyard target = new TargetCardInGraveyard();
            for (Permanent permanent : sacCost.getPermanents()) {
                target.add(permanent.getId(), game);
                delayedAbility.getTargets().add(target);
            }
        }
    }
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) ExileSpellEffect(mage.abilities.effects.common.ExileSpellEffect) Effect(mage.abilities.effects.Effect) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost)

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