From b8a6afedb14a1d54d77df918dc1d5b53be11c44b Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Sat, 28 Nov 2020 00:21:43 +0100 Subject: Make all transactions available Sometimes the strategic move can be to spend more money on a different player, rather than less money on the wrong player. We need to make these strategic moves available through the UI. To make up for the explosion in combinations, we just have to get rid of the options that result in the same money for each neighbour. As long as we give the same amounts, we don't care whether it's for wood or clay. Related: https://github.com/joffrey-bion/seven-wonders/issues/50 --- .../org/luxons/sevenwonders/ui/components/game/Hand.kt | 14 +++++++------- .../kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'sw-ui') diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt index 373ad0f1..a5ce0357 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt @@ -7,7 +7,7 @@ import kotlinx.html.DIV import org.luxons.sevenwonders.model.* import org.luxons.sevenwonders.model.cards.CardPlayability import org.luxons.sevenwonders.model.cards.HandCard -import org.luxons.sevenwonders.model.resources.PricedResourceTransactions +import org.luxons.sevenwonders.model.resources.ResourceTransactionOptions import org.luxons.sevenwonders.model.wonders.WonderBuildability import org.luxons.sevenwonders.ui.redux.TransactionSelectorState import react.* @@ -120,7 +120,7 @@ class HandComponent(props: HandProps) : RComponent(props) { large = true, intent = Intent.SUCCESS, disabled = !card.playability.isPlayable, - onClick = { prepareMove(handAction.moveType, card, card.playability.cheapestTransactions) }, + onClick = { prepareMove(handAction.moveType, card, card.playability.transactionOptions) }, ) { bpIcon(handAction.icon) if (card.playability.isPlayable && !card.playability.isFree) { @@ -136,7 +136,7 @@ class HandComponent(props: HandProps) : RComponent(props) { large = true, intent = Intent.PRIMARY, disabled = !wonderBuildability.isBuildable, - onClick = { prepareMove(MoveType.UPGRADE_WONDER, card, wonderBuildability.cheapestTransactions) }, + onClick = { prepareMove(MoveType.UPGRADE_WONDER, card, wonderBuildability.transactionsOptions) }, ) { bpIcon("key-shift") if (wonderBuildability.isBuildable && !wonderBuildability.isFree) { @@ -145,10 +145,10 @@ class HandComponent(props: HandProps) : RComponent(props) { } } - private fun prepareMove(moveType: MoveType, card: HandCard, transactions: Set) { - when (transactions.size) { - 1 -> props.prepareMove(PlayerMove(moveType, card.name, transactions.first())) - else -> props.startTransactionsSelection(TransactionSelectorState(moveType, card, transactions)) + private fun prepareMove(moveType: MoveType, card: HandCard, transactionOptions: ResourceTransactionOptions) { + when (transactionOptions.size) { + 1 -> props.prepareMove(PlayerMove(moveType, card.name, transactionOptions.first())) + else -> props.startTransactionsSelection(TransactionSelectorState(moveType, card, transactionOptions)) } } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt index ef1f0362..3de763b4 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt @@ -9,7 +9,7 @@ import org.luxons.sevenwonders.model.api.PlayerDTO import org.luxons.sevenwonders.model.api.State import org.luxons.sevenwonders.model.cards.CardBack import org.luxons.sevenwonders.model.cards.HandCard -import org.luxons.sevenwonders.model.resources.PricedResourceTransactions +import org.luxons.sevenwonders.model.resources.ResourceTransactionOptions import redux.RAction data class SwState( @@ -40,7 +40,7 @@ data class GameState( data class TransactionSelectorState( val moveType: MoveType, val card: HandCard, - val transactionsOptions: Set, + val transactionsOptions: ResourceTransactionOptions, ) fun rootReducer(state: SwState, action: RAction): SwState = state.copy( -- cgit