diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2020-11-26 01:26:11 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2020-11-26 02:02:47 +0100 |
commit | 2ec501685f346257051c0f4063f119246c6e02a0 (patch) | |
tree | 2c309463ae7cb08a25c6de3141326a7909b92b00 /sw-common-model | |
parent | Distinguish wonder fully built and card already played (diff) | |
download | seven-wonders-2ec501685f346257051c0f4063f119246c6e02a0.tar.gz seven-wonders-2ec501685f346257051c0f4063f119246c6e02a0.tar.bz2 seven-wonders-2ec501685f346257051c0f4063f119246c6e02a0.zip |
Support ex-aequo ranks
Diffstat (limited to 'sw-common-model')
-rw-r--r-- | sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt index c1f5e4d3..34dc0d99 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt @@ -3,7 +3,21 @@ package org.luxons.sevenwonders.model.score import kotlinx.serialization.Serializable @Serializable -class ScoreBoard(val scores: Collection<PlayerScore>) +class ScoreBoard(val scores: List<PlayerScore>) { + + @OptIn(ExperimentalStdlibApi::class) + val ranks = buildList { + var r = 1 + add(1) + for (i in 1..scores.lastIndex) { + if (scores[i] < scores[i - 1]) { + add(++r) + } else { + add(r) + } + } + } +} @Serializable data class PlayerScore( |