summaryrefslogtreecommitdiff
path: root/sw-server
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-03-23 21:41:44 +0100
committerJoffrey Bion <joffrey.bion@booking.com>2020-03-23 21:41:44 +0100
commit2b62a334d6e8951d6b0f6bb5d32ac0df3c9e7e70 (patch)
tree874f7f4c418f9b5d0f805ff2fca52e30985f41d2 /sw-server
parentInsignificant cleanup (diff)
downloadseven-wonders-2b62a334d6e8951d6b0f6bb5d32ac0df3c9e7e70.tar.gz
seven-wonders-2b62a334d6e8951d6b0f6bb5d32ac0df3c9e7e70.tar.bz2
seven-wonders-2b62a334d6e8951d6b0f6bb5d32ac0df3c9e7e70.zip
Add whether game can be started in LobbyDTO
Diffstat (limited to 'sw-server')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt2
2 files changed, 3 insertions, 1 deletions
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
bgstack15