Search in sources :

Example 41 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class CelestialKirinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
    if (spell != null) {
        int cmc = spell.getManaValue();
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));
        return new DestroyAllEffect(filter).apply(game, source);
    }
    return false;
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) Spell(mage.game.stack.Spell) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 42 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class ComeuppanceEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    PreventionEffectData preventionData = preventDamageAction(event, source, game);
    if (preventionData.getPreventedDamage() > 0) {
        MageObject damageDealingObject = game.getObject(event.getSourceId());
        UUID objectControllerId = null;
        if (damageDealingObject instanceof Permanent) {
            if (damageDealingObject.isCreature(game)) {
                ((Permanent) damageDealingObject).damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game);
            } else {
                objectControllerId = ((Permanent) damageDealingObject).getControllerId();
            }
        } else if (damageDealingObject instanceof Ability) {
            objectControllerId = ((Ability) damageDealingObject).getControllerId();
        } else if (damageDealingObject instanceof Spell) {
            objectControllerId = ((Spell) damageDealingObject).getControllerId();
        }
        if (objectControllerId != null) {
            Player objectController = game.getPlayer(objectControllerId);
            if (objectController != null) {
                objectController.damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game);
            }
        }
    }
    return true;
}
Also used : Ability(mage.abilities.Ability) PreventionEffectData(mage.abilities.effects.PreventionEffectData) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Example 43 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class CommandeerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
    if (controller != null && spell != null) {
        spell.setControllerId(controller.getId());
        spell.chooseNewTargets(game, controller.getId(), false, false, null);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Example 44 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class CommitEffect 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) {
            return controller.putCardOnTopXOfLibrary(permanent, game, source, 2, true);
        }
        Spell spell = game.getStack().getSpell(source.getFirstTarget());
        if (spell != null) {
            return controller.putCardOnTopXOfLibrary(spell, game, source, 2, true);
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) TargetSpellOrPermanent(mage.target.common.TargetSpellOrPermanent) FilterSpellOrPermanent(mage.filter.common.FilterSpellOrPermanent) Permanent(mage.game.permanent.Permanent) Spell(mage.game.stack.Spell)

Example 45 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class ForkEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpell(source.getFirstTarget());
    if (spell == null) {
        return false;
    }
    spell.createCopyOnStack(game, source, source.getControllerId(), true, 1, ForkApplier.instance);
    return true;
}
Also used : Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Aggregations

Spell (mage.game.stack.Spell)311 Player (mage.players.Player)155 Permanent (mage.game.permanent.Permanent)90 UUID (java.util.UUID)79 MageObject (mage.MageObject)69 Card (mage.cards.Card)51 TargetSpell (mage.target.TargetSpell)48 StackObject (mage.game.stack.StackObject)42 FilterCard (mage.filter.FilterCard)38 FilterSpell (mage.filter.FilterSpell)36 FixedTarget (mage.target.targetpointer.FixedTarget)33 MageObjectReference (mage.MageObjectReference)24 Effect (mage.abilities.effects.Effect)22 OneShotEffect (mage.abilities.effects.OneShotEffect)22 Target (mage.target.Target)22 Ability (mage.abilities.Ability)20 SpellAbility (mage.abilities.SpellAbility)16 FilterPermanent (mage.filter.FilterPermanent)15 TargetCard (mage.target.TargetCard)15 TargetPlayer (mage.target.TargetPlayer)14