From 0ca4028cdb58cc7649da04c0c2b16479ecd83d79 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Mon, 30 Mar 2020 11:30:32 +0200 Subject: Send turn info without hands when entering game --- .../org/luxons/sevenwonders/server/controllers/GameController.kt | 4 +--- .../org/luxons/sevenwonders/server/controllers/LobbyController.kt | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'sw-server/src/main/kotlin') 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 803cca78..733259b9 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 @@ -6,6 +6,7 @@ import org.luxons.sevenwonders.model.Action import org.luxons.sevenwonders.model.PlayerTurnInfo import org.luxons.sevenwonders.model.api.actions.PrepareMoveAction import org.luxons.sevenwonders.model.cards.PreparedCard +import org.luxons.sevenwonders.model.hideHandsAndWaitForReadiness import org.luxons.sevenwonders.server.api.toDTO import org.luxons.sevenwonders.server.lobby.Player import org.luxons.sevenwonders.server.repositories.PlayerRepository @@ -92,9 +93,6 @@ class GameController @Autowired constructor( } } - private fun Collection.hideHandsAndWaitForReadiness() = - map { it.copy(action = Action.SAY_READY, hand = null) } - companion object { private val logger = LoggerFactory.getLogger(GameController::class.java) } diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt index 04fb2228..ee1c6271 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt @@ -3,6 +3,7 @@ package org.luxons.sevenwonders.server.controllers import org.hildan.livedoc.core.annotations.Api import org.luxons.sevenwonders.model.api.actions.ReorderPlayersAction import org.luxons.sevenwonders.model.api.actions.UpdateSettingsAction +import org.luxons.sevenwonders.model.hideHandsAndWaitForReadiness import org.luxons.sevenwonders.server.api.toDTO import org.luxons.sevenwonders.server.lobby.Lobby import org.luxons.sevenwonders.server.lobby.Player @@ -101,7 +102,10 @@ class LobbyController @Autowired constructor( val game = lobby.startGame() logger.info("Game {} successfully started", game.id) - template.convertAndSend("/topic/lobby/" + lobby.id + "/started", Unit) + game.getCurrentTurnInfo().hideHandsAndWaitForReadiness().forEach { + val player = lobby.getPlayers()[it.playerIndex] + template.convertAndSendToUser(player.username, "/queue/lobby/" + lobby.id + "/started", it) + } } companion object { -- cgit