diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-05 17:43:41 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-12 09:15:07 +0200 |
commit | 47b33a1f3726a5b0ce9c60ec843ee66ee3689104 (patch) | |
tree | f3cb3541a9346cea44b9075b9fa610b094466233 /sw-common-model/src | |
parent | Move tests to their proper place (diff) | |
download | seven-wonders-47b33a1f3726a5b0ce9c60ec843ee66ee3689104.tar.gz seven-wonders-47b33a1f3726a5b0ce9c60ec843ee66ee3689104.tar.bz2 seven-wonders-47b33a1f3726a5b0ce9c60ec843ee66ee3689104.zip |
Move score to common model (to enable passing it to client)
Diffstat (limited to 'sw-common-model/src')
-rw-r--r-- | sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt | 27 |
1 files changed, 27 insertions, 0 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 new file mode 100644 index 00000000..ca117c1d --- /dev/null +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt @@ -0,0 +1,27 @@ +package org.luxons.sevenwonders.model.score + +import kotlinx.serialization.Serializable + +@Serializable +class ScoreBoard(val scores: Collection<PlayerScore>) + +@Serializable +data class PlayerScore( + val boardGold: Int, + val pointsByCategory: Map<ScoreCategory, Int> +) : Comparable<PlayerScore> { + + val totalPoints = pointsByCategory.map { it.value }.sum() + + override fun compareTo(other: PlayerScore) = compareValuesBy(this, other, { it.totalPoints }, { it.boardGold }) +} + +enum class ScoreCategory { + CIVIL, + SCIENCE, + MILITARY, + TRADE, + GUILD, + WONDER, + GOLD +} |