Пример #1
0
 @RequestMapping(value = "/board", method = RequestMethod.GET)
 public String boardAll(ModelMap model, HttpSession session) {
   if (playerService.isSingleBoardGame()) {
     String playerName = (String) session.getAttribute("playerName");
     if (playerName == null) {
       return "redirect:/register";
     }
     return "redirect:/board/" + playerName;
   }
   gameSettings(model);
   model.addAttribute("players", playerService.getPlayers());
   model.addAttribute("allPlayersScreen", true);
   return "board";
 }
Пример #2
0
 @RequestMapping(value = "/board/{playerName}", method = RequestMethod.GET)
 public String board(ModelMap model, @PathVariable("playerName") String playerName) {
   Player player = playerService.findPlayer(playerName);
   if (player == null) {
     model.addAttribute("players", EMPTY_LIST);
   } else {
     model.addAttribute("players", Collections.singletonList(player));
     model.addAttribute("playerName", player.getName());
   }
   model.addAttribute("allPlayersScreen", false);
   gameSettings(model);
   return "board";
 }
Пример #3
0
  @RequestMapping(value = "/leaderboard", method = RequestMethod.GET)
  public String leaderBoard(ModelMap model) {
    List<Player> players = new ArrayList<Player>(playerService.getPlayers());
    Collections.sort(
        players,
        new Comparator<Player>() {
          @Override
          public int compare(Player player1, Player player2) {
            return player2.getScore() - player1.getScore();
          }
        });

    model.addAttribute("players", players);
    return "leaderboard";
  }
Пример #4
0
 private void gameSettings(ModelMap model) {
   model.addAttribute("boardSize", playerService.getBoardSize());
   model.addAttribute("gameType", playerService.getGameType());
 }