summaryrefslogtreecommitdiff
path: root/sw-common-model
diff options
context:
space:
mode:
Diffstat (limited to 'sw-common-model')
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt8
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt12
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt4
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 7b228d4d..14e6146a 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,8 +2,8 @@ package org.luxons.sevenwonders.model.cards
import kotlinx.serialization.Serializable
import org.luxons.sevenwonders.model.boards.Requirements
-import org.luxons.sevenwonders.model.resources.PricedResourceTransactions
-import org.luxons.sevenwonders.model.resources.noTransactions
+import org.luxons.sevenwonders.model.resources.ResourceTransactionOptions
+import org.luxons.sevenwonders.model.resources.singleOptionNoTransactionNeeded
interface Card {
val name: String
@@ -82,7 +82,7 @@ data class CardPlayability(
val isPlayable: Boolean,
val isChainable: Boolean = false,
val minPrice: Int = Int.MAX_VALUE,
- val cheapestTransactions: Set<PricedResourceTransactions> = setOf(noTransactions()),
+ val transactionOptions: ResourceTransactionOptions = singleOptionNoTransactionNeeded(),
val playabilityLevel: PlayabilityLevel,
) {
val isFree: Boolean = minPrice == 0
@@ -92,7 +92,7 @@ data class CardPlayability(
isPlayable = true,
isChainable = false,
minPrice = 0,
- cheapestTransactions = setOf(noTransactions()),
+ transactionOptions = singleOptionNoTransactionNeeded(),
playabilityLevel = PlayabilityLevel.SPECIAL_FREE,
)
}
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 51e7f78d..fc99a41d 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
@@ -57,4 +57,16 @@ data class PricedResourceTransaction(
typealias PricedResourceTransactions = Set<PricedResourceTransaction>
+typealias ResourceTransactionOptions = List<PricedResourceTransactions>
+
+val PricedResourceTransactions.totalPrice: Int
+ get() = sumBy { it.totalPrice }
+
+val ResourceTransactionOptions.bestPrice: Int
+ get() = minOfOrNull { it.totalPrice } ?: Int.MAX_VALUE
+
fun noTransactions(): PricedResourceTransactions = emptySet()
+
+fun noTransactionOptions(): ResourceTransactionOptions = emptyList()
+
+fun singleOptionNoTransactionNeeded(): ResourceTransactionOptions = listOf(noTransactions())
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 56b22e82..4767804a 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.PricedResourceTransactions
+import org.luxons.sevenwonders.model.resources.ResourceTransactionOptions
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<PricedResourceTransactions>,
+ val transactionsOptions: ResourceTransactionOptions,
val playabilityLevel: PlayabilityLevel,
) {
val isFree: Boolean = minPrice == 0
bgstack15