diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2020-11-28 02:24:28 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2020-11-28 02:26:32 +0100 |
commit | 3f09112912e4b418bea18a4709fec03587393dda (patch) | |
tree | 04b8fdbead780dc8d2a0eb94492e81e17d20aee4 /sw-common-model | |
parent | Group resources in a 2x2 matrix when there are 4 (diff) | |
download | seven-wonders-3f09112912e4b418bea18a4709fec03587393dda.tar.gz seven-wonders-3f09112912e4b418bea18a4709fec03587393dda.tar.bz2 seven-wonders-3f09112912e4b418bea18a4709fec03587393dda.zip |
Fix score board deserialization
Resolves:
https://github.com/joffrey-bion/seven-wonders/issues/52
Diffstat (limited to 'sw-common-model')
-rw-r--r-- | sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt | 21 |
1 files changed, 11 insertions, 10 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 34dc0d99..36d0857f 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,20 +3,21 @@ package org.luxons.sevenwonders.model.score import kotlinx.serialization.Serializable @Serializable -class ScoreBoard(val scores: List<PlayerScore>) { +data 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) + val ranks: List<Int> + get() = buildList { + var r = 1 + add(1) + for (i in 1..scores.lastIndex) { + if (scores[i] < scores[i - 1]) { + add(++r) + } else { + add(r) + } } } - } } @Serializable |