示例#1
0
 /**
  * Ends the current game and starts if neccessary the next game
  *
  * @return true if table can be closed
  */
 public boolean endGameAndStartNextGame() {
   // get player that chooses who goes first
   Game game = match.getGame();
   if (game == null) {
     return true;
   }
   UUID choosingPlayerId = match.getChooser();
   match.endGame();
   if (ConfigSettings.getInstance().isSaveGameActivated() && !game.isSimulation()) {
     if (GameManager.getInstance().saveGame(game.getId())) {
       match.setReplayAvailable(true);
     }
   }
   GameManager.getInstance().removeGame(game.getId());
   try {
     if (!match.hasEnded()) {
       if (match.getGame() != null && match.getGame().getGameType().isSideboardingAllowed()) {
         sideboard();
       }
       if (!match.hasEnded()) {
         startGame(choosingPlayerId);
       } else {
         closeTable();
       }
     } else {
       closeTable();
     }
   } catch (GameException ex) {
     logger.fatal(null, ex);
   }
   return match.hasEnded();
 }
示例#2
0
 public synchronized void startMatch() {
   if (table.getState().equals(TableState.STARTING)) {
     try {
       if (table.isTournamentSubTable()) {
         logger.info(
             "Tourn. match started id:"
                 + match.getId()
                 + " tournId: "
                 + table.getTournament().getId());
       } else {
         User user = UserManager.getInstance().getUser(userId);
         logger.info(
             "MATCH started ["
                 + match.getName()
                 + "] "
                 + match.getId()
                 + "("
                 + user.getName()
                 + ")");
         logger.debug(
             "- " + match.getOptions().getGameType() + " - " + match.getOptions().getDeckType());
       }
       match.startMatch();
       startGame(null);
     } catch (GameException ex) {
       logger.fatal("Error starting match ", ex);
       match.endGame();
     }
   }
 }