11<template >
2- <ActionBox :instruction-title =" t (' rules.action.price.title' )" :currentCard =" currentCard " :managedByApp =" managedByApp " >
2+ <ActionBox :instruction-title =" t (' rules.action.price.title' )" :currentCard =" currentCard " :managedByApp =" true " >
33 <template #action >
44 <div class =" action" >
55 <AppIcon type="action" :name =" iconName " class="icon"/>
66 </div >
7- <div class =" mt-3" v-if =" managedByApp || done" >
8- <div class =" mb-2" v-html =" t('rules.action.price.priceIncreased', selectedFlowers.length)" ></div >
9- <FlowerIcon v-for =" flower in selectedFlowers " :key =" flower " :flower =" flower " />
10- </div >
11- <div v-else class =" mt-3" @click.stop >
12- <p v-html =" t('rules.action.price.selectFlowers')" ></p >
13- <FlowerSelection v-model =" selectedFlowers " :marketPrices =" navigationState .marketPrices " :max =" flowerCount " />
14- <div v-if =" selectedFlowers.length == flowerCount" class =" mt-2" >
15- <button class =" btn btn-secondary" @click =" windowIsDefined()" >{{t('rules.action.price.windowDefined')}}</button >
16- </div >
17- <div v-if =" selectedFlowers.length == 0" >
18- <div >{{t('rules.action.price.or')}}</div >
19- <div class =" mt-1" >
20- <button class =" btn btn-secondary" @click =" windowIsUndefined()" >{{t('rules.action.price.windowUndefined')}}</button >
21- </div >
22- </div >
23- </div >
7+ <div class =" mt-2 mb-1" v-html =" t('rules.action.price.priceIncreased', flowers.length)" ></div >
8+ <FlowerIcon v-for =" flower in flowers " :key =" flower " :flower =" flower " />
249 </template >
2510 <template #instruction >
2611 <p v-html =" t('rules.action.price.definedWindowInstruction')" />
@@ -37,8 +22,6 @@ import Card from '@/services/Card'
3722import { BotAction } from ' @/services/BotActions'
3823import ActionBox from ' ../ActionBox.vue'
3924import AppIcon from ' @/components/structure/AppIcon.vue'
40- import FlowerSelection from ' @/components/structure/FlowerSelection.vue'
41- import PriceSelection from ' @/services/enum/PriceSelection'
4225import FlowerIcon from ' @/components/structure/FlowerIcon.vue'
4326import WindowSelection from ' @/services/enum/WindowSelection'
4427
@@ -48,21 +31,17 @@ export default defineComponent({
4831 components: {
4932 ActionBox ,
5033 AppIcon ,
51- FlowerSelection ,
5234 FlowerIcon
5335 },
5436 emits: [' ready' ],
5537 setup(props ) {
5638 const { t } = useI18n ()
5739
58- // window already defined?
5940 const floor = props .action .floor ?? 1
6041 const windowSelection = props .action .windowSelection ?? WindowSelection .LEFT
61- const windowState = props .navigationState .botPersistence .windowStates .getWindowState (floor , windowSelection )
62- const selectedFlowers = ref (windowState ?.flowers ?? [])
63- const managedByApp = (windowState != undefined )
42+ const flowers = props .action .flowers ?? []
6443
65- return { t , floor , windowSelection , selectedFlowers , managedByApp }
44+ return { t , floor , windowSelection , flowers }
6645 },
6746 props: {
6847 action: {
@@ -91,32 +70,8 @@ export default defineComponent({
9170 return this .floor
9271 }
9372 },
94- methods: {
95- windowIsDefined() : void {
96- this .navigationState .botPersistence .windowStates .setWindowState (this .floor , this .windowSelection , this .selectedFlowers , [])
97- this .doIncreasePrices ()
98- },
99- windowIsUndefined() : void {
100- if (this .action .priceSelection == PriceSelection .MOST_EXPENSIVE ) {
101- this .selectedFlowers = [this .navigationState .marketPrices .getMostExpensiveFlower ()]
102- }
103- else {
104- this .selectedFlowers = [this .navigationState .marketPrices .getCheapestFlower ()]
105- }
106- this .doIncreasePrices ()
107- },
108- doIncreasePrices() : void {
109- for (const flower of this .selectedFlowers ) {
110- this .navigationState .marketPrices .increase (flower )
111- }
112- this .done = true
113- this .$emit (' ready' )
114- }
115- },
11673 mounted() {
117- if (this .managedByApp ) {
118- this .$emit (' ready' )
119- }
74+ this .$emit (' ready' )
12075 }
12176})
12277 </script >
0 commit comments