summaryrefslogtreecommitdiff
path: root/sw-server
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-07-01 02:12:33 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-07-01 02:12:33 +0200
commit304fce1591e9458ec62441643d71db661cb17a2e (patch)
tree96e668b9e875032b0a3f33f9c48fd16becfca3c5 /sw-server
parentFix style (diff)
downloadseven-wonders-304fce1591e9458ec62441643d71db661cb17a2e.tar.gz
seven-wonders-304fce1591e9458ec62441643d71db661cb17a2e.tar.bz2
seven-wonders-304fce1591e9458ec62441643d71db661cb17a2e.zip
Keep wonders associated to the same player when reordering players
Diffstat (limited to 'sw-server')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt2
1 files changed, 2 insertions, 0 deletions
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 89d041f0..dd2b6561 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
@@ -80,7 +80,9 @@ class Lobby(
if (orderedUsernames.toSet() != usernames.toSet()) {
throw PlayerListMismatchException(orderedUsernames)
}
+ val wondersMap = players.indices.associate { assignedWonders[it] to players[it].username }
players.sortBy { orderedUsernames.indexOf(it.username) }
+ assignedWonders.sortBy { orderedUsernames.indexOf(wondersMap[it]) }
}
@Synchronized
bgstack15