Package mage.game.stack

Examples of mage.game.stack.StackObject


            if (permanent != null && filterTarget.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
                if (filterSource == null) {
                    return true;
                }
                else {
                    StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
                    if (sourceObject != null && filterSource.match(sourceObject, sourceObject.getSourceId(), game)) {
                        return true;
                    }
                }
            }
        }
View Full Code Here


    private boolean checkSpellOnTopOfStackCondition(String[] groups, Game game) {
        if (groups.length > 2 && groups[2].startsWith("spellOnTopOfStack=")) {
            String spellOnTopOFStack = groups[2].substring(18);
            if (game.getStack().size() > 0) {
                StackObject stackObject = game.getStack().getFirst();
                if (stackObject != null && stackObject.getStackAbility().toString().contains(spellOnTopOFStack)) {
                    return true;
                }
            }
            return false;
        }
View Full Code Here

    public void watch(GameEvent event, Game game) {
        if (condition == true) {// no need to check - condition has already occured
            return;
        }
        if (event.getType() == EventType.COUNTERED) {
            StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
            if (stackObject == null) {
                stackObject = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK);
            }
            StackObject counterObject = game.getStack().getStackObject(event.getSourceId());
            if (counterObject == null) {
                counterObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
            }
            if (stackObject != null && counterObject != null
                    && stackObject.getCardType().contains(CardType.CREATURE)
                    && game.getOpponents(controllerId).contains(counterObject.getControllerId())) {
                condition = true;
            }
        }
    }
View Full Code Here

    }

    @Override
    public void watch(GameEvent event, Game game) {
        if (event.getType() == GameEvent.EventType.SPELL_CAST || event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
            StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
            if (stackObject == null) {
                stackObject = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK);
            }
            if (stackObject != null && stackObject.getStackAbility() != null) {
                for (Target target: stackObject.getStackAbility().getTargets()) {
                    if (target instanceof TargetSpell && target.getFirstTarget() != null) {
                        casted.put(getKey(target.getFirstTarget(), stackObject.getSourceId()), stackObject.getControllerId());
                    }
                }
            }
        }
    }
View Full Code Here

        return new CounterUnlessPaysEffect(this);
    }

    @Override
    public boolean apply(Game game, Ability source) {
        StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source));
        if (spell != null) {
            Player player = game.getPlayer(spell.getControllerId());
            if (player != null) {
                Cost costToPay;
                if (cost != null) {
                    costToPay = cost.copy();
                } else  {
                    costToPay = new GenericManaCost(genericMana.calculate(game, source, this));
                }
                String message;
                if (costToPay instanceof ManaCost) {
                    message = "Would you like to pay " + costToPay.getText() + " to prevent counter effect?";
                } else {
                    message = costToPay.getText() + " to prevent counter effect?";
                }
                costToPay.clearPaid();
                if (!(player.chooseUse(Outcome.Benefit, message, game) && costToPay.pay(source, game, spell.getSourceId(), spell.getControllerId(), false))) {
                    return game.getStack().counter(spell.getId(), source.getSourceId(), game);
                }
                return true;
            }
        }
        return false;
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Spell sourceSpell = (Spell) game.getObject(source.getId());
        if (sourceSpell == null || !sourceSpell.isCopiedSpell()) {
            MageObject mageObject = game.getObject(source.getSourceId());
            if (mageObject instanceof StackObject) {
                StackObject sourceCard = (StackObject) mageObject;
                ReboundEffectCastFromExileDelayedTrigger trigger = new ReboundEffectCastFromExileDelayedTrigger(sourceCard.getSourceId(), sourceCard.getSourceId());
                trigger.setControllerId(source.getControllerId());
                game.addDelayedTriggeredAbility(trigger);

                game.getContinuousEffects().addEffect(new ReboundCastFromHandReplacementEffect(source.getSourceId()), source);
                return true;
View Full Code Here

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType() == EventType.TARGET) {
            Permanent attachment = game.getPermanent(source.getSourceId());
            if (attachment != null && event.getTargetId().equals(attachment.getAttachedTo())) {
                StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
                if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
                    return true;
                }
            }
        }
View Full Code Here

        setEndTurnRequested(true);
       
        // 1) All spells and abilities on the stack are exiled. This includes Time Stop, though it will continue to resolve.
        // It also includes spells and abilities that can't be countered.
        while (!game.getStack().isEmpty()) {
            StackObject stackObject = game.getStack().removeLast();
            if (stackObject instanceof Spell) {
                ((Spell) stackObject).moveToExile(null, "", null, game);
            }
        }
        // 2) All attacking and blocking creatures are removed from combat.
View Full Code Here

    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getSourceId().equals(this.sourceId)) {
            StackObject spell = game.getStack().getStackObject(this.sourceId);
            if (spell instanceof Spell) {
                Card card = game.getCard(spell.getSourceId());
                if (card != null) {
                    for (Ability ability: card.getAbilities()) {
                        if (ability instanceof ReplicateAbility) {
                            if (((ReplicateAbility) ability).isActivated()) {
                                for (Effect effect : this.getEffects()) {
View Full Code Here

        }
        return false;
    }

    private UUID getSourceControllerId(UUID sourceId, Game game) {
        StackObject source = game.getStack().getStackObject(sourceId);
        if (source != null) {
            return source.getControllerId();
        }
        Permanent permanent = game.getBattlefield().getPermanent(sourceId);
        if (permanent != null) {
            return permanent.getControllerId();
        }
View Full Code Here

TOP

Related Classes of mage.game.stack.StackObject

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.