Search in sources :

Example 71 with Spell

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

the class AshioksErasureReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
    if (controller == null || sourceObject == null || spell == null) {
        return false;
    }
    UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    return controller.moveCardsToExile(spell, source, game, true, exileId, sourceObject.getIdName());
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) UUID(java.util.UUID) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Example 72 with Spell

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

the class CloudhoofKirinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
    if (spell != null) {
        Player targetPlayer = null;
        for (Target target : source.getTargets()) {
            if (target instanceof TargetPlayer) {
                targetPlayer = game.getPlayer(target.getFirstTarget());
            }
        }
        int cmc = spell.getManaValue();
        if (targetPlayer != null && cmc > 0) {
            targetPlayer.millCards(cmc, source, game);
            return true;
        }
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Target(mage.target.Target) Spell(mage.game.stack.Spell) TargetPlayer(mage.target.TargetPlayer)

Example 73 with Spell

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

the class CurseOfShakenFaithEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent enchantment = game.getPermanentOrLKIBattlefield(sourceId);
    if (enchantment != null) {
        UUID enchantedPlayerId = enchantment.getAttachedTo();
        Spell spell = game.getSpell(event.getTargetId());
        if (spell != null && spell.isControlledBy(enchantedPlayerId)) {
            if (event.getType() == GameEvent.EventType.COPIED_STACKOBJECT) {
                return true;
            }
            SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
            if (watcher != null) {
                return watcher.getSpellsCastThisTurn(enchantedPlayerId).size() > 1;
            }
        }
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) SpellsCastWatcher(mage.watchers.common.SpellsCastWatcher) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Example 74 with Spell

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

the class DwarvenShrineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int count = 0;
    MageObject mageObject = game.getObject(source.getSourceId());
    if (mageObject != null) {
        Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject);
        if (spell != null) {
            Player controller = game.getPlayer(spell.getControllerId());
            if (controller != null) {
                String name = spell.getName();
                FilterCard filterCardName = new FilterCard();
                filterCardName.add(new NamePredicate(name));
                for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
                    Player player = game.getPlayer(playerId);
                    if (player != null) {
                        count += player.getGraveyard().count(filterCardName, game);
                    }
                }
                controller.damage(count * 2, mageObject.getId(), source, game);
                return true;
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) MageObject(mage.MageObject) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Example 75 with Spell

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

the class GalvanicIterationAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!isControlledBy(event.getPlayerId())) {
        return false;
    }
    Spell spell = game.getStack().getSpell(event.getTargetId());
    if (spell == null || !spell.isInstantOrSorcery(game)) {
        return false;
    }
    this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Spell(mage.game.stack.Spell)

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