From 304fce1591e9458ec62441643d71db661cb17a2e Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Wed, 1 Jul 2020 02:12:33 +0200 Subject: Keep wonders associated to the same player when reordering players --- sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt | 2 ++ 1 file changed, 2 insertions(+) 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 -- cgit