diff options
Diffstat (limited to 'sw-common-model/src/commonMain/kotlin')
3 files changed, 4 insertions, 10 deletions
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Api.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Api.kt index 946c93c7..7fe266b9 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Api.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Api.kt @@ -20,10 +20,7 @@ data class LobbyDTO( ) { fun joinability(userDisplayName: String): Actionability = when { state != State.LOBBY -> Actionability(false, "Cannot join: the game has already started") - maxPlayersReached -> Actionability( - false, - "Cannot join: the game is full" - ) + maxPlayersReached -> Actionability(false, "Cannot join: the game is full") playerNameAlreadyUsed(userDisplayName) -> Actionability( false, "Cannot join: already a player named '$userDisplayName' in this game" @@ -32,10 +29,7 @@ data class LobbyDTO( } fun startability(username: String): Actionability = when { - !hasEnoughPlayers -> Actionability( - false, - "Cannot start the game, more players needed" - ) + !hasEnoughPlayers -> Actionability(false, "Cannot start the game, more players needed") owner != username -> Actionability(false, "Cannot start the game: only the owner can") else -> Actionability(true, "Start game") } diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt index 7368fbd1..5ddca2c6 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt @@ -14,7 +14,7 @@ enum class ResourceType(val symbol: Char) { companion object { - private val typesPerSymbol = values().map { it.symbol to it }.toMap() + private val typesPerSymbol = values().associateBy { it.symbol } fun fromSymbol(symbol: String): ResourceType { if (symbol.length != 1) { 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 ca117c1d..10fe02e1 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 @@ -11,7 +11,7 @@ data class PlayerScore( val pointsByCategory: Map<ScoreCategory, Int> ) : Comparable<PlayerScore> { - val totalPoints = pointsByCategory.map { it.value }.sum() + val totalPoints = pointsByCategory.values.sum() override fun compareTo(other: PlayerScore) = compareValuesBy(this, other, { it.totalPoints }, { it.boardGold }) } |