protected void callMessageReceived(CallMessage msg) { try { Phase phase = game.getPhase(); logger.debug("Delegating {} on phase {}", msg.getMethod(), phase.getClass().getSimpleName()); msg.call(phase, ClientIF.class); phase = game.getPhase(); // new phase can differ from the phase in prev msg.call !!! while (phase != null && !phase.isEntered()) { logger.debug("Entering phase {}", phase.getClass().getSimpleName()); phase.setEntered(true); phase.enter(); phase = game.getPhase(); game.fireGameEvent().phaseEntered(phase); } } catch (InvocationTargetException ie) { logger.error(ie.getMessage(), ie.getCause()); } catch (Exception e) { logger.error(e.getMessage(), e); } }
public boolean closeGame(boolean force) { boolean isGameRunning = getJMenuBar().isGameRunning(); if (config.getConfirm().getGame_close() && isGameRunning && !(game.getPhase() instanceof GameOverPhase)) { if (localServer != null) { String options[] = {_("Close game"), _("Cancel") }; int result = JOptionPane.showOptionDialog(this, _("Game is running. Do you really want to quit game and also disconnect all other players?"), _("Close game"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (JOptionPane.OK_OPTION != result) return false; } else { String options[] = {_("Close game"), _("Cancel") }; int result = JOptionPane.showOptionDialog(this, _("Game is running. Do you really want to leave it?"), _("Close game"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (JOptionPane.OK_OPTION != result) return false; } } setTitle(BASE_TITLE); resetWindowIcon(); if (localServer != null) { localServer.stop(); localServer = null; } else if (server != null) { getClientStub().stop(); } server = null; activePlayer = null; getJMenuBar().setIsGameRunning(false); if (controlPanel != null) { controlPanel.closeGame(); mainPanel.closeGame(); } if (discardedTilesDialog != null) { discardedTilesDialog.dispose(); discardedTilesDialog = null; getJMenuBar().setShowDiscardedEnabled(false); } return true; }