From 719fcf03862174be1454731c59128d278e9523be Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Fri, 27 Nov 2020 01:25:09 +0100 Subject: Introduce priced transactions This is useful to provide information about the price per provider. --- .../kotlin/org/luxons/sevenwonders/model/cards/Cards.kt | 4 ++-- .../org/luxons/sevenwonders/model/resources/Resources.kt | 16 ++++++++++++++-- .../org/luxons/sevenwonders/model/wonders/Wonders.kt | 4 ++-- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'sw-common-model/src/commonMain/kotlin/org') 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 = setOf(noTransactions()), + val cheapestTransactions: Set = 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) +sealed class ResourceTransaction { + abstract val provider: Provider + abstract val resources: List +} typealias ResourceTransactions = Set -fun noTransactions(): ResourceTransactions = emptySet() +@Serializable +data class PricedResourceTransaction( + override val provider: Provider, + override val resources: List, + val totalPrice: Int, +) : ResourceTransaction() + +typealias PricedResourceTransactions = Set + +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, + val cheapestTransactions: Set, val playabilityLevel: PlayabilityLevel, ) { val isFree: Boolean = minPrice == 0 -- cgit