Package mage.game.stack

Examples of mage.game.stack.StackAbility


                    Player controller = game.getPlayer(source.getControllerId());
                    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
                    if (ability != null && controller != null) {
                        Ability newAbility = ability.copy();
                        newAbility.newId();
                        game.getStack().push(new StackAbility(newAbility, source.getControllerId()));
                        if (newAbility.getTargets().size() > 0) {
                            if (controller.chooseUse(newAbility.getEffects().get(0).getOutcome(), "Choose new targets?", game)) {
                                newAbility.getTargets().clearChosen();
                                if (newAbility.getTargets().chooseTargets(newAbility.getEffects().get(0).getOutcome(), source.getControllerId(), newAbility, game) == false) {
                                    return false;
View Full Code Here


            if (stackObject instanceof Spell) {
                Spell spell = (Spell)stackObject;
                sourceAbility = spell.getSpellAbility();
                targets = spell.getSpellAbility().getTargets();
            } else if (stackObject instanceof StackAbility) {
                StackAbility stackAbility = (StackAbility)stackObject;
                sourceAbility = stackAbility;
                targets = stackAbility.getTargets();
            } else {
                return false;
            }
            boolean twoTimesTarget = false;
            if (targets.size() == 1 && targets.get(0).getTargets().size() == 1) {
View Full Code Here

            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(newAbility);
                        newEffect.getTarget().addTarget(targetId, newAbility, sim);
                        sim.getStack().push(newAbility);
                        SimulationNode2 newNode = new SimulationNode2(node, sim, depth, ability.getControllerId());
                        node.children.add(newNode);
View Full Code Here

    public boolean triggerAbility(TriggeredAbility source, Game game) {
        Ability ability = source.copy();
        List<Ability> options = getPlayableOptions(ability, game);
        if (options.isEmpty()) {
            logger.debug("simulating -- triggered ability:" + ability);
            game.getStack().push(new StackAbility(ability, playerId));
            ability.activate(game, false);
            game.applyEffects();
            game.getPlayers().resetPassed();
        }
        else {
View Full Code Here

        return true;
    }

    protected void addAbilityNode(SimulationNode2 parent, Ability ability, int depth, Game game) {
        Game sim = game.copy();
        sim.getStack().push(new StackAbility(ability, playerId));
        ability.activate(sim, false);
        sim.applyEffects();
        SimulationNode2 newNode = new SimulationNode2(parent, sim, depth, playerId);
        logger.debug("simulating -- node #:" + SimulationNode2.getCount() + " triggered ability option");
        for (Target target: ability.getTargets()) {
View Full Code Here

   
    @Override
    public String getTargetedName(Game game) {
        StringBuilder sb = new StringBuilder("activated ability (");
        for (UUID targetId: getTargets()) {
            StackAbility object = (StackAbility) game.getObject(targetId);
            if (object != null) {
                sb.append(object.getRule()).append(" ");
            }
        }
        sb.append(")");
        return sb.toString();
    }
View Full Code Here

    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
            StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
            if (stackAbility.getAbilityType() == AbilityType.ACTIVATED) {
                this.getTargets().get(0).add(event.getPlayerId(), game);
                return true;
            }
        }
        return false;
View Full Code Here

    }
   
    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == EventType.ACTIVATED_ABILITY) {
            StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
            if (!(stackAbility.getStackAbility() instanceof ManaAbility)) {
                Effect effect = this.getEffects().get(0);
                effect.setValue("stackAbility", stackAbility.getStackAbility());
                return true;
            }
        }
        return false;
    }
View Full Code Here

                    Player controller = game.getPlayer(source.getControllerId());
                    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
                    if (ability != null && controller != null) {
                        Ability newAbility = ability.copy();
                        newAbility.newId();
                        game.getStack().push(new StackAbility(newAbility, source.getControllerId()));
                        if (newAbility.getTargets().size() > 0) {
                            if (controller.chooseUse(newAbility.getEffects().get(0).getOutcome(), "Choose new targets?", game)) {
                                newAbility.getTargets().clearChosen();
                                if (newAbility.getTargets().chooseTargets(newAbility.getEffects().get(0).getOutcome(), source.getControllerId(), newAbility, game) == false) {
                                    return false;
View Full Code Here

    @Override
    public void watch(GameEvent event, Game game) {
        if (event.getType() == EventType.ACTIVATED_ABILITY) {
            StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
            if (stackObject != null) {
                StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getTargetId());
                if (stackAbility != null && stackAbility.getAbilityType() == AbilityType.ACTIVATED) {
                    this.activatedThisTurn.add(stackAbility.getOriginalId());
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of mage.game.stack.StackAbility

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.