@Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getSourceId().equals(source.getSourceId())) { return !TurnPhase.COMBAT.equals(game.getTurn().getPhaseType()) || game.getStep().getType().equals(PhaseStep.DECLARE_BLOCKERS) || game.getStep().getType().equals(PhaseStep.FIRST_COMBAT_DAMAGE) || game.getStep().getType().equals(PhaseStep.COMBAT_DAMAGE) || game.getStep().getType().equals(PhaseStep.END_COMBAT); } return false; }
protected int simulatePostCombatMain( Game game, SimulationNode2 node, int depth, int alpha, int beta) { if (ALLOW_INTERRUPT && Thread.interrupted()) { Thread.currentThread().interrupt(); logger.debug("interrupted"); return GameStateEvaluator2.evaluate(playerId, game); } logger.debug("Sim [" + depth + "] -- 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, depth, alpha, beta); } // return simulateCounterAttack(game, node, depth, alpha, beta); return GameStateEvaluator2.evaluate(playerId, game); }
protected int simulateCombat( Game game, SimulationNode2 node, int depth, int alpha, int beta, boolean counter) { Integer val = null; if (ALLOW_INTERRUPT && Thread.interrupted()) { Thread.currentThread().interrupt(); logger.debug("interrupted"); return GameStateEvaluator2.evaluate(playerId, game); } if (game.getTurn().getStepType() != PhaseStep.DECLARE_BLOCKERS) { game.getTurn().setPhase(new CombatPhase()); if (game.getPhase().beginPhase(game, game.getActivePlayerId())) { simulateStep(game, new BeginCombatStep()); game.getPhase().setStep(new DeclareAttackersStep()); if (!game.getStep().skipStep(game, game.getActivePlayerId())) { game.fireEvent( new GameEvent( GameEvent.EventType.DECLARE_ATTACKERS_STEP_PRE, null, null, game.getActivePlayerId())); if (!game.replaceEvent( GameEvent.getEvent( GameEvent.EventType.DECLARING_ATTACKERS, game.getActivePlayerId(), game.getActivePlayerId()))) { val = simulateAttackers( game, node, game.getActivePlayerId(), depth, alpha, beta, counter); } } else if (!counter) { simulateToEnd(game); val = simulatePostCombatMain(game, node, depth, alpha, beta); } } } else { if (!game.getStep().skipStep(game, game.getActivePlayerId())) { game.fireEvent( new GameEvent( GameEvent.EventType.DECLARE_BLOCKERS_STEP_PRE, null, null, game.getActivePlayerId())); if (!game.replaceEvent( GameEvent.getEvent( GameEvent.EventType.DECLARING_BLOCKERS, game.getActivePlayerId(), game.getActivePlayerId()))) { // only suitable for two player games - only simulates blocks for 1st defender val = simulateBlockers( game, node, game.getCombat().getDefenders().iterator().next(), depth, alpha, beta, counter); } } else if (!counter) { finishCombat(game); /// val = simulateCounterAttack(game, node, depth, alpha, beta); } } if (val == null) { val = GameStateEvaluator2.evaluate(playerId, game); } if (logger.isDebugEnabled()) { logger.debug( "returning -- combat score: " + val + " depth:" + depth + " for player:" + game.getPlayer(node.getPlayerId()).getName()); } return val; }