From 3f09112912e4b418bea18a4709fec03587393dda Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Sat, 28 Nov 2020 02:24:28 +0100 Subject: Fix score board deserialization Resolves: https://github.com/joffrey-bion/seven-wonders/issues/52 --- .../org/luxons/sevenwonders/model/score/Score.kt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'sw-common-model') 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) { +data class ScoreBoard(val scores: List) { @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 + 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 -- cgit