diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2020-11-27 01:25:09 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2020-11-27 14:38:45 +0100 |
commit | 719fcf03862174be1454731c59128d278e9523be (patch) | |
tree | a9d9c02497ea82dd36bdda7c7fa1a2a3c9ca674e /sw-common-model/src | |
parent | Use Kotlinx Serialization in Spring Boot instead of Jackson (diff) | |
download | seven-wonders-719fcf03862174be1454731c59128d278e9523be.tar.gz seven-wonders-719fcf03862174be1454731c59128d278e9523be.tar.bz2 seven-wonders-719fcf03862174be1454731c59128d278e9523be.zip |
Introduce priced transactions
This is useful to provide information about the price per provider.
Diffstat (limited to 'sw-common-model/src')
3 files changed, 18 insertions, 6 deletions
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt index 16cd6ca1..7b228d4d 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt @@ -2,7 +2,7 @@ package org.luxons.sevenwonders.model.cards import kotlinx.serialization.Serializable import org.luxons.sevenwonders.model.boards.Requirements -import org.luxons.sevenwonders.model.resources.ResourceTransactions +import org.luxons.sevenwonders.model.resources.PricedResourceTransactions import org.luxons.sevenwonders.model.resources.noTransactions interface Card { @@ -82,7 +82,7 @@ data class CardPlayability( val isPlayable: Boolean, val isChainable: Boolean = false, val minPrice: Int = Int.MAX_VALUE, - val cheapestTransactions: Set<ResourceTransactions> = setOf(noTransactions()), + val cheapestTransactions: Set<PricedResourceTransactions> = setOf(noTransactions()), val playabilityLevel: PlayabilityLevel, ) { val isFree: Boolean = minPrice == 0 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 0ebb837d..51e7f78d 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 @@ -41,8 +41,20 @@ enum class Provider(val boardPosition: RelativeBoardPosition) { } @Serializable -data class ResourceTransaction(val provider: Provider, val resources: List<CountedResource>) +sealed class ResourceTransaction { + abstract val provider: Provider + abstract val resources: List<CountedResource> +} typealias ResourceTransactions = Set<ResourceTransaction> -fun noTransactions(): ResourceTransactions = emptySet() +@Serializable +data class PricedResourceTransaction( + override val provider: Provider, + override val resources: List<CountedResource>, + val totalPrice: Int, +) : ResourceTransaction() + +typealias PricedResourceTransactions = Set<PricedResourceTransaction> + +fun noTransactions(): PricedResourceTransactions = emptySet() diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt index a99f4f58..56b22e82 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable import org.luxons.sevenwonders.model.boards.Requirements import org.luxons.sevenwonders.model.cards.CardBack import org.luxons.sevenwonders.model.cards.PlayabilityLevel -import org.luxons.sevenwonders.model.resources.ResourceTransactions +import org.luxons.sevenwonders.model.resources.PricedResourceTransactions import org.luxons.sevenwonders.model.resources.ResourceType import kotlin.random.Random @@ -58,7 +58,7 @@ data class ApiWonderStage( data class WonderBuildability( val isBuildable: Boolean, val minPrice: Int, - val cheapestTransactions: Set<ResourceTransactions>, + val cheapestTransactions: Set<PricedResourceTransactions>, val playabilityLevel: PlayabilityLevel, ) { val isFree: Boolean = minPrice == 0 |