summaryrefslogtreecommitdiff
path: root/sw-ui/src
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-05-26 11:08:15 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-05-26 11:08:15 +0200
commit036bf7136cb09c83c6aa1114d2d0f57f59c9bd0e (patch)
tree3f6dfedbc64657bdcc998e8ba80fbe68d54dbf2a /sw-ui/src
parentImprove "say ready" message (diff)
downloadseven-wonders-036bf7136cb09c83c6aa1114d2d0f57f59c9bd0e.tar.gz
seven-wonders-036bf7136cb09c83c6aa1114d2d0f57f59c9bd0e.tar.bz2
seven-wonders-036bf7136cb09c83c6aa1114d2d0f57f59c9bd0e.zip
Add price info in hand button title
Diffstat (limited to 'sw-ui/src')
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt28
1 files changed, 17 insertions, 11 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 bbb6afbb..1db3e0b0 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
@@ -23,11 +23,7 @@ import kotlinx.css.maxHeight
import kotlinx.css.maxWidth
import kotlinx.css.pct
import kotlinx.css.position
-import kotlinx.css.properties.boxShadow
-import kotlinx.css.properties.s
-import kotlinx.css.properties.transform
-import kotlinx.css.properties.transition
-import kotlinx.css.properties.translate
+import kotlinx.css.properties.*
import kotlinx.css.px
import kotlinx.css.rem
import kotlinx.css.vh
@@ -44,6 +40,7 @@ import react.RBuilder
import styled.StyledDOMBuilder
import styled.css
import styled.styledDiv
+import kotlin.math.absoluteValue
fun RBuilder.handComponent(
cards: List<HandCard>,
@@ -103,7 +100,7 @@ private fun RBuilder.actionButtons(card: HandCard, wonderBuildability: WonderBui
}
}
bpButtonGroup {
- bpButton(title = "PLAY",
+ bpButton(title = "PLAY (${priceText(-card.playability.minPrice)})",
large = true,
intent = Intent.SUCCESS,
icon = "play",
@@ -111,8 +108,9 @@ private fun RBuilder.actionButtons(card: HandCard, wonderBuildability: WonderBui
onClick = {
val transactions = card.playability.cheapestTransactions.firstOrNull() ?: noTransactions()
prepareMove(PlayerMove(MoveType.PLAY, card.name, transactions))
- })
- bpButton(title = "UPGRADE WONDER",
+ }
+ )
+ bpButton(title = "UPGRADE WONDER (${priceText(-wonderBuildability.minPrice)})",
large = true,
intent = Intent.PRIMARY,
icon = "key-shift",
@@ -120,16 +118,24 @@ private fun RBuilder.actionButtons(card: HandCard, wonderBuildability: WonderBui
onClick = {
val wonderTransactions = wonderBuildability.cheapestTransactions.firstOrNull() ?: noTransactions()
prepareMove(PlayerMove(MoveType.UPGRADE_WONDER, card.name, wonderTransactions))
- })
- bpButton(title = "DISCARD",
+ }
+ )
+ bpButton(title = "DISCARD (+3 coins)", // TODO remove hardcoded value
large = true,
intent = Intent.DANGER,
icon = "cross",
- onClick = { prepareMove(PlayerMove(MoveType.DISCARD, card.name)) })
+ onClick = { prepareMove(PlayerMove(MoveType.DISCARD, card.name)) }
+ )
}
}
}
+private fun priceText(amount: Int) = when (amount.absoluteValue) {
+ 0 -> "free"
+ 1 -> "$amount coin"
+ else -> "$amount coins"
+}
+
private fun CSSBuilder.handStyle() {
alignItems = Align.center
bottom = 0.px
bgstack15