diff options
Diffstat (limited to 'sw-engine/src/main/kotlin/org/luxons')
-rw-r--r-- | sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt index 1d03aa76..4872f44f 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt @@ -6,6 +6,8 @@ import org.luxons.sevenwonders.engine.boards.Board import org.luxons.sevenwonders.engine.resources.* import org.luxons.sevenwonders.model.resources.ResourceTransactions import org.luxons.sevenwonders.model.resources.bestPrice +import org.luxons.sevenwonders.model.resources.noTransactionOptions +import org.luxons.sevenwonders.model.resources.totalPrice @Serializable data class Requirements internal constructor( @@ -36,15 +38,16 @@ data class Requirements internal constructor( } private fun satisfactionWithPotentialHelp(player: Player): RequirementsSatisfaction { - val options = transactionOptions(resources, player) - val minPrice = options.bestPrice + gold - if (options.isEmpty()) { + val allOptions = transactionOptions(resources, player) + if (allOptions.isEmpty()) { return RequirementsSatisfaction.unavailableResources() } - if (player.board.gold < minPrice) { - return RequirementsSatisfaction.missingGoldForResources(minPrice, options) + val minPrice = allOptions.bestPrice + gold + if (minPrice > player.board.gold) { + return RequirementsSatisfaction.missingGoldForResources(minPrice, noTransactionOptions()) } - return RequirementsSatisfaction.metWithHelp(minPrice, options) + val availableOptions = allOptions.filter { it.totalPrice + gold <= player.board.gold } + return RequirementsSatisfaction.metWithHelp(minPrice, availableOptions) } /** |