diff options
Diffstat (limited to 'sw-server/src')
-rw-r--r-- | sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt | 11 | ||||
-rw-r--r-- | sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt index 32359d58..be5d916b 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt @@ -76,6 +76,9 @@ class GameController @Autowired constructor( logger.info("Game {}: all players have prepared their move, executing turn...", game.id) game.playTurn() sendTurnInfo(player.lobby.getPlayers(), game, true) + if (game.endOfGameReached()) { + player.lobby.setEndOfGame() + } } return action.move } @@ -105,6 +108,14 @@ class GameController @Autowired constructor( } } + @MessageMapping("/game/leave") + fun leave(principal: Principal) { + val player = principal.player + val game = player.game + player.leave() + logger.info("Game {}: player {} left the game", game.id, principal.name) + } + companion object { private val logger = LoggerFactory.getLogger(GameController::class.java) } diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt index eadc1742..24bf5066 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt @@ -88,6 +88,10 @@ class Lobby( return player } + fun setEndOfGame() { + state = State.FINISHED + } + internal class GameAlreadyStartedException(name: String) : IllegalStateException("Game '$name' has already started") |