diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-15 00:29:30 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-15 01:20:15 +0200 |
commit | 813ef5907819226e62a8255eea10d7fffc0df843 (patch) | |
tree | ebbc1f93e128c75168806403cdb28fabe43369c1 /sw-common-model | |
parent | Upgrade to krossbow 0.20.1 (migrate to flows) (diff) | |
download | seven-wonders-813ef5907819226e62a8255eea10d7fffc0df843.tar.gz seven-wonders-813ef5907819226e62a8255eea10d7fffc0df843.tar.bz2 seven-wonders-813ef5907819226e62a8255eea10d7fffc0df843.zip |
Clean up
Diffstat (limited to 'sw-common-model')
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 }) } |