protected int simulatePostCombatMain(Game game, SimulationNode node, int alpha, int beta) { if (Thread.interrupted()) { Thread.currentThread().interrupt(); logger.debug(indent(node.depth) + "interrupted"); return GameStateEvaluator.evaluate(playerId, game); } logger.debug(indent(node.depth) + "simulating -- post combat main"); game.getTurn().setPhase(new PostCombatMainPhase()); if (game.getPhase().beginPhase(game, game.getActivePlayerId())) { game.getPhase().setStep(new PostCombatMainStep()); game.getStep().beginStep(game, playerId); game.getPlayers().resetPassed(); return addActions(node, alpha, beta); } return simulateCounterAttack(game, node, alpha, beta); }
game.getPlayers().resetPassed(); playNext(game, game.getActivePlayerId(), node);
@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; }
game.getPlayers().resetPassed();
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()); }
game.getPlayers().resetPassed(); game.getPlayerList().setCurrent(game.getActivePlayerId());
while (!isPaused() && !checkIfGameIsOver() && !this.getTurn().isEndTurnRequested()) { if (!resuming) { state.getPlayers().resetPassed(); state.getPlayerList().setCurrent(activePlayerId); } else { checkConcede(); applyEffects(); state.getPlayers().resetPassed(); fireUpdatePlayersEvent(); resetShortLivingLKI();
game.getPlayers().resetPassed();