Skip to content

Commit

Permalink
Add roomId parameter when starting a game
Browse files Browse the repository at this point in the history
  • Loading branch information
ricksu978 committed Feb 18, 2024
1 parent 77d9dea commit 7e4262d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface GameService {
}

data class StartGameRequest(
val roomId: String,
val players: List<GamePlayer>,
) {
data class GamePlayer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ class StartGameUseCase(
}

private fun Room.startGameByHost(jwtToken: String): StartedGameEvent {
if(roomId == null) {
throw PlatformException(GAME_START_FAILED, "Room Id is null")
}
val gameServerHost = game.backEndUrl
val startGameRequest = StartGameRequest(players.map { it.toGamePlayer() })
val startGameRequest = StartGameRequest(roomId.toString(), players.map { it.toGamePlayer() })
val startGameResponse = gameService.startGame(gameServerHost, jwtToken, startGameRequest)

return StartedGameEvent(GAME_STARTED, Data(startGameResponse.url, roomId!!))
Expand Down

0 comments on commit 7e4262d

Please sign in to comment.