From 47b33a1f3726a5b0ce9c60ec843ee66ee3689104 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Tue, 5 May 2020 17:43:41 +0200 Subject: Move score to common model (to enable passing it to client) --- .../org/luxons/sevenwonders/model/score/Score.kt | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt (limited to 'sw-common-model/src') 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) + +@Serializable +data class PlayerScore( + val boardGold: Int, + val pointsByCategory: Map +) : Comparable { + + 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 +} -- cgit