From 2b62a334d6e8951d6b0f6bb5d32ac0df3c9e7e70 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Mon, 23 Mar 2020 21:41:44 +0100 Subject: Add whether game can be started in LobbyDTO --- .../src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt | 2 +- sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'sw-server/src/main/kotlin') diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt index 6f0fc180..390dc839 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt @@ -7,7 +7,7 @@ import org.luxons.sevenwonders.server.lobby.Player fun Lobby.toDTO(currentUser: String): LobbyDTO { val players = getPlayers().map { it.toDTO(currentUser) } - return LobbyDTO(id, name, owner.username, players, state) + return LobbyDTO(id, name, owner.username, players, state, canBeStarted()) } fun Player.toDTO(currentUser: String) = 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 7158a417..599d889f 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 @@ -57,6 +57,8 @@ class Lobby( return game } + fun canBeStarted(): Boolean = hasEnoughPlayers() + private fun hasEnoughPlayers(): Boolean = players.size >= gameDefinition.minPlayers @Synchronized -- cgit