diff options
author | Joffrey Bion <joffrey.bion@gmail.com> | 2021-06-19 15:51:54 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@gmail.com> | 2021-06-19 19:06:30 +0200 |
commit | 5d4eda165a4d01ba78d6f49e7ba3b84b4bdabba9 (patch) | |
tree | fde9f6b310011b00e1f94a4bd80159dd2f3c26ba /sw-ui/src/main | |
parent | Fix ex-aequo ranks (diff) | |
download | seven-wonders-5d4eda165a4d01ba78d6f49e7ba3b84b4bdabba9.tar.gz seven-wonders-5d4eda165a4d01ba78d6f49e7ba3b84b4bdabba9.tar.bz2 seven-wonders-5d4eda165a4d01ba78d6f49e7ba3b84b4bdabba9.zip |
Use ordinals for score ranks
Diffstat (limited to 'sw-ui/src/main')
-rw-r--r-- | sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt index a92857ae..b89a02a8 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt @@ -66,7 +66,7 @@ private fun RBuilder.scoreTable(scoreBoard: ScoreBoard, players: List<PlayerDTO> scoreBoard.scores.forEachIndexed { index, score -> val player = players[score.playerIndex] tr { - centeredTd { +"${scoreBoard.ranks[index]}" } + centeredTd { ordinal(scoreBoard.ranks[index]) } centeredTd { bpIcon(player.icon?.name ?: "user", size = 25) } styledTd { inlineStyles { @@ -98,6 +98,18 @@ private fun RBuilder.scoreTable(scoreBoard: ScoreBoard, players: List<PlayerDTO> } } +private fun RBuilder.ordinal(value: Int) { + +"$value" + sup { +value.ordinalIndicator() } +} + +private fun Int.ordinalIndicator() = when { + this % 10 == 1 && this != 11 -> "st" + this % 10 == 2 && this != 12 -> "nd" + this % 10 == 3 && this != 13 -> "rd" + else -> "th" +} + private fun RBuilder.centeredTh(block: RDOMBuilder<TH>.() -> Unit) { th { // inline styles necessary to overcome blueprintJS overrides |