diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2018-08-01 02:24:40 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2018-08-01 02:24:40 +0200 |
commit | 880a4fff4232317dd00ab0ee9992a33d459b9862 (patch) | |
tree | 9b554fc8870e988e8bdf772642ece558e6df780e /game-engine/src/main | |
parent | Remove checkstyle and add ktlint (diff) | |
download | seven-wonders-880a4fff4232317dd00ab0ee9992a33d459b9862.tar.gz seven-wonders-880a4fff4232317dd00ab0ee9992a33d459b9862.tar.bz2 seven-wonders-880a4fff4232317dd00ab0ee9992a33d459b9862.zip |
Fix comparisons of ResourceTransactions
This commit abstracts away the actual type of collection in the
ResourceTransactions typealias.
Incidentally, it also changes it to Set, so that tests can compare
without concerns about order. This also means that duplicates are not
tolerated anymore, and I still haven't decided whether this is good or bad.
Diffstat (limited to 'game-engine/src/main')
-rw-r--r-- | game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/PlayerMove.kt | 5 | ||||
-rw-r--r-- | game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactions.kt | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/PlayerMove.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/PlayerMove.kt index 95e6b13c..22cc36f0 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/PlayerMove.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/PlayerMove.kt @@ -1,10 +1,11 @@ package org.luxons.sevenwonders.game.api import org.luxons.sevenwonders.game.moves.MoveType -import org.luxons.sevenwonders.game.resources.ResourceTransaction +import org.luxons.sevenwonders.game.resources.ResourceTransactions +import org.luxons.sevenwonders.game.resources.noTransactions data class PlayerMove( val type: MoveType, val cardName: String, - val transactions: Collection<ResourceTransaction> = emptyList() + val transactions: ResourceTransactions = noTransactions() ) diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactions.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactions.kt index c7ab3636..d45d0ce7 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactions.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceTransactions.kt @@ -4,10 +4,10 @@ import org.luxons.sevenwonders.game.Player typealias ResourceTransactions = Collection<ResourceTransaction> -fun noTransactions(): ResourceTransactions = emptyList() +fun noTransactions(): ResourceTransactions = emptySet() -fun Map<Provider, Resources>.toTransactions() = - filter { (_, res) -> !res.isEmpty() }.map { (p, res) -> ResourceTransaction(p, res) } +fun Map<Provider, Resources>.toTransactions(): ResourceTransactions = + filter { (_, res) -> !res.isEmpty() }.map { (p, res) -> ResourceTransaction(p, res) }.toSet() fun ResourceTransactions.asResources(): Resources = map { it.resources }.merge() |