Package mage.game.stack

Examples of mage.game.stack.StackObject


    }

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        StackObject sourceStackObject = game.getStack().getStackObject(source.getSourceId());
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (player != null && sourceStackObject != null && permanent != null) {
            ChoiceColor colorChoice = new ChoiceColor();
            if (player.choose(Outcome.BoostCreature, colorChoice, game)) {
                game.informPlayers(sourceStackObject.getName() + ": " + player.getName() + " has chosen " + colorChoice.getChoice());
                game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
                permanent.addInfo("chosen color", new StringBuilder("<font color='blue'>Chosen color: ").append(colorChoice.getColor().getDescription()).append("</font>").toString());
            }
        }
        return false;
View Full Code Here


    }

    @Override
    public void watch(GameEvent event, Game game) {
       if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY ) {
           StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
           if (stackObject != null &&
                   stackObject.getStackAbility() != null &&
                   stackObject.getStackAbility() instanceof LoyaltyAbility) {
               playerIds.add(stackObject.getControllerId());
           }
       }
    }
View Full Code Here

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType() == GameEvent.EventType.TARGET) {
            Card targetCard = game.getCard(event.getTargetId());
            StackObject stackObject = (StackObject) game.getStack().getStackObject(event.getSourceId());
            if (targetCard != null && stackObject != null && targetCard.getId().equals(source.getSourceId())) {
                if (stackObject.getColor().contains(ObjectColor.BLACK)
                        || stackObject.getColor().contains(ObjectColor.RED)) {
                    if (!stackObject.getControllerId().equals(source.getControllerId())
                            && stackObject.getCardType().contains(CardType.INSTANT)
                            || stackObject.getCardType().contains(CardType.SORCERY)) {
                        return true;
                    }
                }
            }
        }
View Full Code Here

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
            ZoneChangeEvent zcEvent = (ZoneChangeEvent) event;
            if (zcEvent.getFromZone() == Zone.HAND && zcEvent.getToZone() == Zone.GRAVEYARD) {
                StackObject spell = game.getStack().getStackObject(event.getSourceId());
                if (spell != null && game.getOpponents(source.getControllerId()).contains(spell.getControllerId())) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

        }
        return null;
    }

    protected void resolve(SimulationNode node, Game game) {
        StackObject ability = game.getStack().pop();
        if (ability instanceof StackAbility) {
            SearchEffect effect = getSearchEffect((StackAbility) ability);
            if (effect != null && ability.getControllerId().equals(playerId)) {
                Target target = effect.getTarget();
                if (!target.doneChosing()) {
                    for (UUID targetId: target.possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) {
                        Game sim = game.copy();
                        StackAbility newAbility = (StackAbility) ability.copy();
                        SearchEffect newEffect = getSearchEffect((StackAbility) newAbility);
                        newEffect.getTarget().addTarget(targetId, newAbility, sim);
                        sim.getStack().push(newAbility);
                        SimulationNode newNode = new SimulationNode(node, sim, ability.getControllerId());
                        node.children.add(newNode);
                        newNode.getTargets().add(targetId);
                        logger.debug(indent(node.depth) + "simulating search -- node#: " + SimulationNode.getCount() + "for player: " + sim.getPlayer(ability.getControllerId()).getName());
                    }
                    return;
                }
            }
        }
        logger.debug(indent(node.depth) + "simulating resolve ");
        ability.resolve(game);
        game.applyEffects();
        game.getPlayers().resetPassed();
        game.getPlayerList().setCurrent(game.getActivePlayerId());
    }
View Full Code Here

        SimulationNode test = node.getParent();
        if (test == null)
            return false;
        if (action.isUsesStack()) {
            Game testSim = sim.copy();
            StackObject ability = testSim.getStack().pop();
            ability.resolve(testSim);
            testSim.applyEffects();
            currentVal = GameStateEvaluator.evaluate(playerId, testSim, true);
        }
        else {
            currentVal = GameStateEvaluator.evaluate(playerId, sim, true);
View Full Code Here

    }

    @Override
    public boolean apply(Game game, Ability source) {
        boolean countered = false;
        StackObject stackObject = game.getStack().getStackObject(targetPointer.getFirst(game, source));
        if (game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) {
            countered = true;
        }
        if (stackObject != null) {
            Player controller = game.getPlayer(stackObject.getControllerId());
            if (controller != null) {
                int cardsCount = Math.min(4, controller.getLibrary().size());
                for (int i = 0; i < cardsCount; i++) {
                    Card card = controller.getLibrary().removeFromTop(game);
                    if (card != null) {
View Full Code Here

        if (event.getType() == EventType.ZONE_CHANGE) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
            if ((fromZone == null || zEvent.getFromZone() == fromZone) && (toZone == null || zEvent.getToZone() == toZone)) {
                Card card = game.getCard(event.getTargetId());
                if (card != null && card.getOwnerId().equals(getControllerId()) && card.getCardType().contains(CardType.CREATURE)) {
                    StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
                    if (stackObject == null) {
                        stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
                    }
                    if (stackObject != null) {
                        if (stackObject.getId().equals(lastStackObjectId)) {
                            return false; // was already handled
                        }
                        lastStackObjectId = stackObject.getId();
                        return true;
                    } else {
                        // special action or replacement effect, so we can't check yet if multiple cards are moved with one effect
                        return true;
                    }
View Full Code Here

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        switch (event.getType()) {
            case CREATE_TOKEN:
                StackObject spell = game.getStack().getStackObject(event.getSourceId());
                if (spell != null && spell.getControllerId().equals(source.getControllerId())) {
                    event.setAmount(event.getAmount() * 2);
                }
        }
        return false;
    }
View Full Code Here

    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        UUID eventObject = ((ZoneChangeEvent) event).getTargetId();
        StackObject card = game.getStack().getStackObject(eventObject);
        if (card != null) {
            if (card instanceof Spell) {
                game.rememberLKI(card.getId(), Zone.STACK, (Spell) card);
            }
            if (card instanceof Card && eventObject == cardid) {
                ((Card) card).moveToExile(source.getSourceId(), "Wrexial, The Risen Deep", source.getSourceId(), game);
                return true;
            }
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.