diff options
Diffstat (limited to 'sw-ui-kt')
-rw-r--r-- | sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt | 6 |
1 files changed, 4 insertions, 2 deletions
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<PlayerDTO>): 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<PlayerDTO>.withUserFirst(): List<PlayerDTO> { +private fun List<PlayerDTO?>.withUserFirst(): List<PlayerDTO?> { 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 <T> List<T>.growTo(targetSize: Int): List<T?> { if (size >= targetSize) return this return this + List(targetSize - size) { null } |