Package mage.game.stack

Examples of mage.game.stack.Spell


    @Override
    public boolean applies(Ability abilityToModify, Ability source, Game game) {
        if (abilityToModify instanceof SpellAbility) {
            if (abilityToModify.getControllerId().equals(source.getControllerId())) {
                Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
                if (spell != null) {
                    return this.filter.match(spell, game);
                } else {
                    // used at least for flashback ability because Flashback ability doesn't use stack
                    Card sourceCard = game.getCard(abilityToModify.getSourceId());
View Full Code Here


    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            StackObject stackObject = game.getStack().getStackObject(source.getId());
            Spell spell = (Spell) stackObject;
            spell = spell.copySpell();
            spell.setCopiedSpell(true);
            spell.setControllerId(source.getControllerId());
            // Remove Epic effect from the spell
            Effect epicEffect = null;
            for (Effect effect : spell.getSpellAbility().getEffects()) {
                if (effect instanceof EpicEffect) {
                    epicEffect = effect;
                    break;
                }
            }
            spell.getSpellAbility().getEffects().remove(epicEffect);
            DelayedTriggeredAbility ability = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(new EpicPushEffect(spell, rule), Duration.EndOfGame, false);
            ability.setSourceId(source.getSourceId());
            ability.setControllerId(source.getControllerId());
            game.addDelayedTriggeredAbility(ability);
            game.addEffect(new EpicReplacementEffect(), source);
View Full Code Here

    }

    @Override
    public boolean applies(Ability abilityToModify, Ability source, Game game) {
        if (abilityToModify instanceof SpellAbility) {
            Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
            if (spell != null) {
                return this.filter.match(spell, game);
            } else {
                // used at least for flashback ability because Flashback ability doesn't use stack
                Card sourceCard = game.getCard(abilityToModify.getSourceId());
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        if (spell != null) {
            // don't change the targets of the in the origin copied spell
            Spell copySpell = spell.copy();
            game.getStack().push(copySpell);
            copySpell.chooseNewTargets(game, source.getControllerId());
            return true;
        }

        return false;
    }
View Full Code Here

    }

    @Override
    public boolean applies(Ability abilityToModify, Ability source, Game game) {
        if (abilityToModify instanceof SpellAbility) {
            Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
            if (spell != null) {
                return this.filter.match(spell, game);
            } else {
                // used at least for flashback ability because Flashback ability doesn't use stack
                Card sourceCard = game.getCard(abilityToModify.getSourceId());
View Full Code Here

    @Override
    public boolean applies(Ability abilityToModify, Ability source, Game game) {
        if (abilityToModify instanceof SpellAbility) {
            if (abilityToModify.getControllerId().equals(source.getControllerId())) {
                Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
                if (spell != null) {
                    return this.filter.match(spell, game);
                } else {
                    // used at least for flashback ability because Flashback ability doesn't use stack or for getPlayables where spell is not cast yet
                    Card sourceCard = game.getCard(abilityToModify.getSourceId());
View Full Code Here

            }
            if (!controller.chooseUse(outcome, new StringBuilder("Use effect of ").append(object.getLogName()).append("?").toString(), game)) {
                return false;
            }
        }
        Spell spell = game.getStack().getSpell(event.getSourceId());
        for (Effect effect: baseEffects) {
            if (source.activate(game, false)) {
                if (effect instanceof ContinuousEffect) {
                    game.addEffect((ContinuousEffect) effect, source);
                }
                else {
                    // noxx: commented it out because of resulting in a bug
                    // with CopyEffect (PhantasmalImageTest.java)
                    /*if (spell != null)
                        effect.apply(game, spell.getSpellAbility());
                    else
                        effect.apply(game, source);*/
                    if (spell != null) {
                        effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
                    }
                    effect.apply(game, source);
                }
            }
        }
View Full Code Here

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType().equals(GameEvent.EventType.SPELL_CAST) && event.getSourceId().equals(this.getSourceId())) {
            if (getSourceObject() != null && getSourceObject() instanceof Spell) {
                Spell spell = (Spell)getSourceObject();
                if (spell.getSpellAbility() != null) {
                    for (Effect effect : getEffects()) {
                        effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility());
                    }
                }
            }
            return true;
        }
View Full Code Here

        this.targets = targets;
    }

    @Override
    public boolean apply(MageObject input, Game game) {
        Spell spell = game.getStack().getSpell(input.getId());
        if (spell != null) {
            Targets spellTargets = spell.getSpellAbility().getTargets();
            int numberOfTargets = 0;
            for (Target target : spellTargets) {
                numberOfTargets += target.getTargets().size();
            }
            if (numberOfTargets == targets) {
View Full Code Here

                    break;
                case HAND:
                    game.getPlayer(ownerId).getHand().add(this);
                    break;
                case STACK:
                    game.getStack().push(new Spell(this, this.getSpellAbility().copy(), ownerId, event.getFromZone()));
                    break;
                case EXILED:
                    game.getExile().getPermanentExile().add(this);
                    break;
                case COMMAND:
View Full Code Here

TOP

Related Classes of mage.game.stack.Spell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.