summaryrefslogtreecommitdiff
path: root/sw-ui
diff options
context:
space:
mode:
authorjoffrey-bion <joffrey.bion@gmail.com>2020-11-28 00:21:43 +0100
committerjoffrey-bion <joffrey.bion@gmail.com>2020-11-28 02:26:32 +0100
commitb8a6afedb14a1d54d77df918dc1d5b53be11c44b (patch)
tree58143efb9ab9e91dc045dc5ddbb5aeca99ef3596 /sw-ui
parentAdd dialog to choose who to buy resources from (diff)
downloadseven-wonders-b8a6afedb14a1d54d77df918dc1d5b53be11c44b.tar.gz
seven-wonders-b8a6afedb14a1d54d77df918dc1d5b53be11c44b.tar.bz2
seven-wonders-b8a6afedb14a1d54d77df918dc1d5b53be11c44b.zip
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
Diffstat (limited to 'sw-ui')
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt14
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt4
2 files changed, 9 insertions, 9 deletions
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<HandProps, RState>(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<HandProps, RState>(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<HandProps, RState>(props) {
}
}
- private fun prepareMove(moveType: MoveType, card: HandCard, transactions: Set<PricedResourceTransactions>) {
- 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<PricedResourceTransactions>,
+ val transactionsOptions: ResourceTransactionOptions,
)
fun rootReducer(state: SwState, action: RAction): SwState = state.copy(
bgstack15