diff options
author | jbion <joffrey.bion@amadeus.com> | 2017-05-25 09:59:06 +0200 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2017-05-25 09:59:06 +0200 |
commit | d815a8319fb40ad295892886c108293119918f17 (patch) | |
tree | 47a01c8f321166853365e97fcfba37fef55a525e /backend/src/main | |
parent | Add SevenWondersClient for ease of use in tests (diff) | |
download | seven-wonders-d815a8319fb40ad295892886c108293119918f17.tar.gz seven-wonders-d815a8319fb40ad295892886c108293119918f17.tar.bz2 seven-wonders-d815a8319fb40ad295892886c108293119918f17.zip |
Improve log messages
Diffstat (limited to 'backend/src/main')
3 files changed, 9 insertions, 8 deletions
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<Player> 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 { |