summaryrefslogtreecommitdiff
path: root/sw-server/src
diff options
context:
space:
mode:
Diffstat (limited to 'sw-server/src')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt16
1 files changed, 10 insertions, 6 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 e4c1b39a..70fb3220 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
@@ -4,6 +4,8 @@ import io.micrometer.core.instrument.MeterRegistry
import org.luxons.sevenwonders.engine.Game
import org.luxons.sevenwonders.model.api.GameListEvent
import org.luxons.sevenwonders.model.api.actions.PrepareMoveAction
+import org.luxons.sevenwonders.model.api.events.GameEvent
+import org.luxons.sevenwonders.model.api.events.wrap
import org.luxons.sevenwonders.model.api.wrap
import org.luxons.sevenwonders.model.cards.PreparedCard
import org.luxons.sevenwonders.model.hideHandsAndWaitForReadiness
@@ -102,7 +104,7 @@ class GameController(
handleEndOfGame(game, player, lobby)
}
} else {
- template.convertAndSendToUser(player.username, "/queue/game/preparedMove", action.move)
+ template.convertAndSendToUser(player.username, "/queue/game/events", GameEvent.MovePrepared(action.move).wrap())
}
}
}
@@ -130,18 +132,20 @@ class GameController(
}
}
- private fun sendPlayerReady(gameId: Long, player: Player) =
- template.convertAndSend("/topic/game/$gameId/playerReady", player.username)
+ private fun sendPlayerReady(gameId: Long, player: Player) {
+ template.convertAndSend("/topic/game/$gameId/events", GameEvent.PlayerIsReady(player.username).wrap())
+ }
- private fun sendPreparedCard(gameId: Long, preparedCard: PreparedCard) =
- template.convertAndSend("/topic/game/$gameId/prepared", preparedCard)
+ private fun sendPreparedCard(gameId: Long, preparedCard: PreparedCard) {
+ template.convertAndSend("/topic/game/$gameId/events", GameEvent.CardPrepared(preparedCard).wrap())
+ }
private fun sendTurnInfo(players: List<Player>, game: Game, hideHands: Boolean) {
val turns = game.getCurrentTurnInfo()
val turnsToSend = if (hideHands) turns.hideHandsAndWaitForReadiness() else turns
for (turnInfo in turnsToSend) {
val player = players[turnInfo.playerIndex]
- template.convertAndSendToUser(player.username, "/queue/game/turn", turnInfo)
+ template.convertAndSendToUser(player.username, "/queue/game/events", GameEvent.NewTurnStarted(turnInfo).wrap())
}
}
bgstack15