public boolean usesStack() { if (abilities != null && !abilities.isEmpty()) { return abilities.get(abilities.size() -1).isUsesStack(); } return true; } }
public boolean usesStack() { if (abilities != null && !abilities.isEmpty()) { return abilities.get(abilities.size() -1).isUsesStack(); } return true; } }
protected void act(Game game) { if (actions == null || actions.isEmpty()) pass(game); else { boolean usedStack = false; while (actions.peek() != null) { Ability ability = actions.poll(); this.activateAbility((ActivatedAbility) ability, game); if (logger.isDebugEnabled()) logger.debug("activating: " + ability); if (ability.isUsesStack()) usedStack = true; } if (usedStack) pass(game); } logger.info("Turn " + game.getTurnNum() + " Step " + game.getStep().toString() + " Player " + name + " Life " + life); }
if (ability.isUsesStack()) { usedStack = true;
&& (action.isUsesStack() || action instanceof PassAbility)) {
protected void addAbilityNode(SimulationNode2 parent, Ability ability, int depth, Game game) { Game sim = game.copy(); sim.getStack().push(new StackAbility(ability, playerId)); if (ability.activate(sim, false) && ability.isUsesStack()) { game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId())); } sim.applyEffects(); SimulationNode2 newNode = new SimulationNode2(parent, sim, depth, playerId); logger.debug("simulating -- node #:" + SimulationNode2.getCount() + " triggered ability option"); for (Target target : ability.getTargets()) { for (UUID targetId : target.getTargets()) { newNode.getTargets().add(targetId); } } parent.children.add(newNode); }
if (ability.isUsesStack()) { game.getStack().push(new StackAbility(ability, playerId)); if (ability.activate(game, false)) {
@Override public boolean triggerAbility(TriggeredAbility source, Game game) { Ability ability = source.copy(); List<Ability> options = getPlayableOptions(ability, game); if (options.isEmpty()) { if (logger.isDebugEnabled()) logger.debug("simulating -- triggered ability:" + ability); game.getStack().push(new StackAbility(ability, playerId)); if (ability.activate(game, false) && ability.isUsesStack()) { game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId())); } game.applyEffects(); game.getPlayers().resetPassed(); } else { SimulationNode parent = (SimulationNode) game.getCustomData(); if (parent.getDepth() == maxDepth) return true; logger.debug(indent(parent.getDepth()) + "simulating -- triggered ability - adding children:" + options.size()); for (Ability option: options) { addAbilityNode(parent, option, game); } } return true; }
@Override 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)); if (ability.activate(game, false) && ability.isUsesStack()) { game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId())); } game.applyEffects(); game.getPlayers().resetPassed(); } else { SimulationNode2 parent = (SimulationNode2) game.getCustomData(); int depth = parent.getDepth() - 1; if (depth == 0) { return true; } logger.debug("simulating -- triggered ability - adding children:" + options.size()); for (Ability option : options) { addAbilityNode(parent, option, depth, game); } } return true; }
continue; if (!sim.checkIfGameIsOver() && action.isUsesStack()) {
protected void addAbilityNode(SimulationNode parent, Ability ability, Game game) { Game sim = game.copy(); sim.getStack().push(new StackAbility(ability, playerId)); ability.activate(sim, false); if (ability.activate(sim, false) && ability.isUsesStack()) { game.fireEvent(new GameEvent(GameEvent.EventType.TRIGGERED_ABILITY, ability.getId(), ability.getSourceId(), ability.getControllerId())); } sim.applyEffects(); SimulationNode newNode = new SimulationNode(parent, sim, playerId); logger.debug(indent(newNode.getDepth()) + "simulating -- node #:" + SimulationNode.getCount() + " triggered ability option"); for (Target target: ability.getTargets()) { for (UUID targetId: target.getTargets()) { newNode.getTargets().add(targetId); } } parent.children.add(newNode); }
if (test == null) return false; if (action.isUsesStack()) { Game testSim = sim.copy(); StackObject ability = testSim.getStack().pop();