From d815a8319fb40ad295892886c108293119918f17 Mon Sep 17 00:00:00 2001 From: jbion Date: Thu, 25 May 2017 09:59:06 +0200 Subject: Improve log messages --- .../java/org/luxons/sevenwonders/controllers/GameController.java | 8 ++++---- .../java/org/luxons/sevenwonders/controllers/LobbyController.java | 6 +++--- backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'backend') diff --git a/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java b/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java index c5723658..513a7cdb 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java +++ b/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java @@ -43,14 +43,14 @@ public class GameController { Player player = playerRepository.find(principal.getName()); player.setReady(true); Game game = player.getGame(); - logger.info("Game '{}': player '{}' is ready for the next turn", game.getId(), player); + logger.info("Game {}: player {} is ready for the next turn", game.getId(), player); Lobby lobby = player.getLobby(); List players = lobby.getPlayers(); boolean allReady = players.stream().allMatch(Player::isReady); if (allReady) { - logger.info("Game '{}': all players ready, sending turn info", game.getId()); + logger.info("Game {}: all players ready, sending turn info", game.getId()); players.forEach(p -> p.setReady(false)); sendTurnInfo(players, game); } else { @@ -77,10 +77,10 @@ public class GameController { Game game = player.getGame(); CardBack preparedCardBack = game.prepareMove(player.getIndex(), action.getMove()); PreparedCard preparedCard = new PreparedCard(player, preparedCardBack); - logger.info("Game '{}': player {} prepared move {}", game.getId(), principal.getName(), action.getMove()); + logger.info("Game {}: player {} prepared move {}", game.getId(), principal.getName(), action.getMove()); if (game.allPlayersPreparedTheirMove()) { - logger.info("Game '{}': all players have prepared their move, executing turn...", game.getId()); + logger.info("Game {}: all players have prepared their move, executing turn...", game.getId()); Table table = game.playTurn(); sendPlayedMoves(game.getId(), table); } else { diff --git a/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java b/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java index c3378149..e907981b 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java +++ b/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java @@ -40,9 +40,9 @@ public class LobbyController { @MessageMapping("/lobby/leave") public void leave(Principal principal) { Lobby lobby = getLobby(principal); - lobby.removePlayer(principal.getName()); + Player player = lobby.removePlayer(principal.getName()); - logger.info("Player '{}' left game '{}'", principal.getName(), lobby.getName()); + logger.info("Player {} left game '{}'", player, lobby.getName()); sendLobbyUpdateToPlayers(lobby); } @@ -77,7 +77,7 @@ public class LobbyController { Lobby lobby = getOwnedLobby(principal); Game game = lobby.startGame(); - logger.info("Game '{}' successfully started", game.getId()); + logger.info("Game {} successfully started", game.getId()); template.convertAndSend("/topic/lobby/" + lobby.getId() + "/started", ""); } diff --git a/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java b/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java index 1cd5b3ae..6f8531a1 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java +++ b/backend/src/main/java/org/luxons/sevenwonders/lobby/Lobby.java @@ -123,12 +123,13 @@ public class Lobby { return players.stream().anyMatch(p -> p.getUsername().equals(username)); } - public void removePlayer(String username) throws UnknownPlayerException { + public Player removePlayer(String username) throws UnknownPlayerException { Player player = getPlayer(players, username); players.remove(player); player.setIndex(-1); player.setLobby(null); player.setGame(null); + return player; } static class GameAlreadyStartedException extends IllegalStateException { -- cgit