diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-07-01 02:12:33 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-07-01 02:12:33 +0200 |
commit | 304fce1591e9458ec62441643d71db661cb17a2e (patch) | |
tree | 96e668b9e875032b0a3f33f9c48fd16becfca3c5 /sw-server | |
parent | Fix style (diff) | |
download | seven-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.kt | 2 |
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 |