From 2c36a50874b0858de3c7320560618b0c7ddffb76 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sun, 22 Mar 2020 23:04:46 +0100 Subject: Fix player order by adding placeholders before shifting --- .../org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sw-ui-kt/src/main') diff --git a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt index 472f5811..f096c5db 100644 --- a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt +++ b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt @@ -21,8 +21,8 @@ import styled.styledH5 fun RBuilder.radialPlayerList(players: List): ReactElement { val playerItemBuilders = players - .withUserFirst() .growTo(targetSize = 3) + .withUserFirst() .map { p -> p.elementBuilder() } val tableImgBuilder: ElementBuilder = { roundTableImg() } @@ -48,12 +48,14 @@ private fun RBuilder.roundTableImg(): ReactElement = img { } } -private fun List.withUserFirst(): List { +private fun List.withUserFirst(): List { val nonUsersBeginning = takeWhile { !it.isUser } val userToEnd = subList(nonUsersBeginning.size, size) return userToEnd + nonUsersBeginning } +private val PlayerDTO?.isUser: Boolean get() = this?.isUser ?: false + private fun List.growTo(targetSize: Int): List { if (size >= targetSize) return this return this + List(targetSize - size) { null } -- cgit