11<template >
22 <SideBar :navigationState =" navigationState " />
3- <h1 >{{t('player.player')}}</h1 >
3+ <h1 >{{t('player.player')}}: {{t('sideBar.turn', {turn})}} </h1 >
44
5- <p class =" mt-4" >Select your action:</ p >
5+ <p class =" mt-4" v-html = " t('roundTurnPlayer.selectAction') " / >
66
77 <div class =" actions" >
88 <button class =" btn btn-primary btn-lg" v-if =" !showDeliveryActions" @click =" showDeliveryActions = true" >
9- Make Delivery
9+ {{t('roundTurnPlayer.makeDelivery')}}
1010 </button >
1111 <div class =" deliveryActions" v-if =" showDeliveryActions" >
1212 <button class =" btn btn-primary btn-lg" v-for =" floor of floors" :key =" floor" @click =" deliverToFloor(floor)" >
13- Delivered to Floor {{ floor}}
13+ {{t('roundTurnPlayer.deliveredToFloor', { floor}) }}
1414 </button >
1515 </div >
16- <button class =" btn btn-primary btn-lg" @click = " next " >
17- Buy Flower
16+ <button class =" btn btn-primary btn-lg" data-bs-toggle = " modal " data-bs-target = " #buyFlowerModal " >
17+ {{t('roundTurnPlayer.buyFlower.title')}}
1818 </button >
1919 <button class =" btn btn-primary btn-lg" @click =" next" >
20- Other Action
20+ {{t('roundTurnPlayer.otherAction')}}
2121 </button >
2222 <div >
2323 <button class =" btn btn-outline-danger btn-lg passButton" data-bs-toggle =" modal" data-bs-target =" #passModal" >
2929 </div >
3030 </div >
3131
32+ <ModalDialog id="buyFlowerModal" :title =" t (' roundTurnPlayer.buyFlower.title' )" >
33+ <template #body >
34+ <div >{{t('roundTurnPlayer.buyFlower.selectFlower')}}</div >
35+ <div class =" d-flex flex-wrap gap-2 mb-3" >
36+ <button v-for =" flower in allFlowers" :key =" flower" type =" button"
37+ class =" btn flower-btn" :class =" buyFlowerType === flower ? 'btn-dark' : 'btn-outline-secondary'"
38+ @click =" buyFlowerType = flower" >
39+ <FlowerIcon :flower =" flower " />
40+ </button >
41+ </div >
42+ <div >
43+ {{t('roundTurnPlayer.buyFlower.numberOfFlowers')}}<br />
44+ <NumberInput v-model =" buyFlowerCount " :min =" 1 " :max =" 20 " class="numberInput"/>
45+ </div >
46+ <div class =" mt-3" >
47+ <span >{{t('roundTurnPlayer.buyFlower.totalCost')}}</span >
48+ <span class =" cost" >$<span class =" value" >{{buyFlowerTotalCost}}</span ></span >
49+ </div >
50+ </template >
51+ <template #footer >
52+ <button class =" btn btn-primary" :disabled =" !buyFlowerType || !buyFlowerCount" @click =" buyFlower()" data-bs-dismiss =" modal" >{{t('action.ok')}}</button >
53+ <button class =" btn btn-secondary" data-bs-dismiss =" modal" >{{t('action.cancel')}}</button >
54+ </template >
55+ </ModalDialog >
56+
3257 <ModalDialog id="passModal" :title =" t (' action.pass' )" >
3358 <template #body >
3459 <p v-html =" t('roundTurnPlayer.passConfirm')" ></p >
@@ -52,19 +77,25 @@ import NavigationState from '@/util/NavigationState'
5277import FooterButtons from ' @/components/structure/FooterButtons.vue'
5378import { useStateStore } from ' @/store/state'
5479import ModalDialog from ' @brdgm/brdgm-commons/src/components/structure/ModalDialog.vue'
80+ import NumberInput from ' @brdgm/brdgm-commons/src/components/form/NumberInput.vue'
5581import SideBar from ' @/components/round/SideBar.vue'
5682import DebugInfo from ' @/components/round/DebugInfo.vue'
5783import getSoloBoardPassAction , { SoloBoardPassAction } from ' @/util/getSoloBoardPassAction'
5884import SoloBoardPassActionInfo from ' @/components/round/SoloBoardPassActionInfo.vue'
85+ import FlowerIcon from ' @/components/structure/FlowerIcon.vue'
5986import Player from ' @/services/enum/Player'
87+ import Flower from ' @/services/enum/Flower'
88+ import getBuyFlowerCost from ' @/util/getBuyFlowerCost'
6089
6190export default defineComponent ({
6291 name: ' RoundTurnPlayer' ,
6392 components: {
6493 FooterButtons ,
6594 ModalDialog ,
95+ NumberInput ,
6696 SideBar ,
6797 SoloBoardPassActionInfo ,
98+ FlowerIcon ,
6899 DebugInfo
69100 },
70101 setup() {
@@ -78,8 +109,10 @@ export default defineComponent({
78109
79110 const playerDeliveryFloor = ref (navigationState .playerDeliveryFloor )
80111 const showDeliveryActions = ref (false )
112+ const buyFlowerType = ref (undefined as Flower | undefined )
113+ const buyFlowerCount = ref (1 )
81114
82- return { t , router , navigationState , state , round , turn , playerDeliveryFloor , showDeliveryActions }
115+ return { t , router , navigationState , state , round , turn , playerDeliveryFloor , showDeliveryActions , buyFlowerType , buyFlowerCount }
83116 },
84117 computed: {
85118 backButtonRouteTo() : string {
@@ -91,6 +124,13 @@ export default defineComponent({
91124 floors() : number [] {
92125 return [5 ,4 ,3 ,2 ,1 ]
93126 },
127+ allFlowers() : Flower [] {
128+ return this .navigationState .marketPrices .flowerOrder
129+ },
130+ buyFlowerTotalCost() : number {
131+ const price = this .navigationState .marketPrices .getPrice (this .buyFlowerType ! )
132+ return getBuyFlowerCost (price , this .buyFlowerCount )
133+ },
94134 soloBoardPassAction() : SoloBoardPassAction {
95135 const { soloBoard, playerTurns, playerDeliveryFloor } = this .navigationState
96136 return getSoloBoardPassAction (soloBoard , playerTurns , playerDeliveryFloor )
@@ -105,6 +145,13 @@ export default defineComponent({
105145 this .playerDeliveryFloor = floor
106146 this .next ()
107147 },
148+ buyFlower() : void {
149+ if (this .buyFlowerType && this .buyFlowerCount ) {
150+ const newPrice = this .navigationState .marketPrices .getPrice (this .buyFlowerType ) + this .buyFlowerCount
151+ this .navigationState .marketPrices .setPrice (this .buyFlowerType , newPrice )
152+ this .next ()
153+ }
154+ },
108155 next() : void {
109156 this .nextWithPassed (false )
110157 },
@@ -153,4 +200,17 @@ export default defineComponent({
153200 justify-content : center ;
154201 align-items : center ;
155202}
203+ .flower-btn {
204+ padding : 0.4rem 0.6rem ;
205+ }
206+ .cost {
207+ color : darkred ;
208+ margin-left : 0.25rem ;
209+ .value {
210+ font-weight : bold ;
211+ }
212+ }
213+ .numberInput {
214+ width : 4rem ;
215+ }
156216 </style >
0 commit comments