Skip to content

Commit a75342b

Browse files
committed
price action
1 parent cd0bf83 commit a75342b

22 files changed

Lines changed: 238 additions & 36 deletions

src/components/round/BotAction.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="actionItem">
33
<component :is="componentName" :action="action" :navigationState="navigationState" :currentCard="currentCard"
4-
@ready="$emit('ready')"/>
4+
@ready="(ready: boolean) => $emit('ready', ready)"/>
55
</div>
66
</template>
77

@@ -35,7 +35,7 @@ export default defineComponent({
3535
ActionXp
3636
},
3737
emits: {
38-
ready: () => true
38+
ready: (_ready: boolean) => true
3939
},
4040
setup() {
4141
const { t } = useI18n()

src/components/round/DebugInfo.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<b>Current Card</b>: {{navigationState.botPersistence.cardDeck.currentCard}}<br/>
66
<b>Card Deck</b>: {{ navigationState.botPersistence.cardDeck.toPersistence() }}<br/>
77
<b>Bot Garden</b>: {{ navigationState.botPersistence.garden.toPersistence() }}<br/>
8+
<b>Defined Windows</b>: {{ navigationState.botPersistence.definedWindows.toPersistence() }}<br/>
89
<b>Player Turn:</b> {{ navigationState.playerTurn}}/{{ navigationState.playerTurns }}, <b>Delivery Floor:</b> {{ navigationState.playerDeliveryFloor }}<br/>
910
<b>Bot Turn:</b> {{ navigationState.botTurn}}/{{ navigationState.botTurns }}, <b>Claimed Milestones:</b> {{navigationState.botPersistence.claimedMilestones}}<br/>
1011
<b>Solo Board Pass Action</b>: {{ navigationState.soloBoardPassAction }}

src/components/round/botAction/ActionBillboard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineComponent({
2828
AppIcon
2929
},
3030
emits: {
31-
ready: () => true
31+
ready: (_ready: boolean) => true
3232
},
3333
setup() {
3434
const { t } = useI18n()
@@ -49,7 +49,7 @@ export default defineComponent({
4949
}
5050
},
5151
mounted() {
52-
this.$emit('ready')
52+
this.$emit('ready', true)
5353
}
5454
})
5555
</script>

src/components/round/botAction/ActionDelivery.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineComponent({
2828
AppIcon
2929
},
3030
emits: {
31-
ready: () => true
31+
ready: (_ready: boolean) => true
3232
},
3333
setup() {
3434
const { t } = useI18n()
@@ -49,7 +49,7 @@ export default defineComponent({
4949
}
5050
},
5151
mounted() {
52-
this.$emit('ready')
52+
this.$emit('ready', true)
5353
}
5454
})
5555
</script>

src/components/round/botAction/ActionPaid.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineComponent({
2828
AppIcon
2929
},
3030
emits: {
31-
ready: () => true
31+
ready: (_ready: boolean) => true
3232
},
3333
setup() {
3434
const { t } = useI18n()
@@ -49,7 +49,7 @@ export default defineComponent({
4949
}
5050
},
5151
mounted() {
52-
this.$emit('ready')
52+
this.$emit('ready', true)
5353
}
5454
})
5555
</script>

src/components/round/botAction/ActionPlant.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default defineComponent({
3131
FlowerIcon
3232
},
3333
emits: {
34-
ready: () => true
34+
ready: (_ready: boolean) => true
3535
},
3636
setup() {
3737
const { t } = useI18n()
@@ -52,7 +52,7 @@ export default defineComponent({
5252
}
5353
},
5454
mounted() {
55-
this.$emit('ready')
55+
this.$emit('ready', true)
5656
}
5757
})
5858
</script>

src/components/round/botAction/ActionPrice.vue

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,68 @@
11
<template>
2-
<ActionBox :instruction-title="t('rules.action.price.title')" :currentCard="currentCard">
2+
<ActionBox :instruction-title="t('rules.action.price.title')" :currentCard="currentCard" :managedByApp="managedByApp">
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>
724
</template>
825
<template #instruction>
9-
<p v-html="t('rules.action.price.instruction')"/>
26+
<p v-html="t('rules.action.price.definedWindowInstruction')"/>
27+
<p v-html="t(`rules.action.price.undefinedWindowInstruction.${action.priceSelection}`)"/>
1028
</template>
1129
</ActionBox>
1230
</template>
1331

1432
<script lang="ts">
15-
import { defineComponent, PropType } from 'vue'
33+
import { defineComponent, PropType, ref } from 'vue'
1634
import { useI18n } from 'vue-i18n'
1735
import NavigationState from '@/util/NavigationState'
1836
import Card from '@/services/Card'
1937
import { BotAction } from '@/services/BotActions'
2038
import ActionBox from '../ActionBox.vue'
2139
import AppIcon from '@/components/structure/AppIcon.vue'
40+
import FlowerSelection from '@/components/structure/FlowerSelection.vue'
41+
import getWindowSelectionFloorCount from '@/util/getWindowSelectionFloorCount'
42+
import PriceSelection from '@/services/enum/PriceSelection'
43+
import FlowerIcon from '@/components/structure/FlowerIcon.vue'
2244
2345
export default defineComponent({
2446
name: 'ActionPrice',
2547
inheritAttrs: false,
2648
components: {
2749
ActionBox,
28-
AppIcon
50+
AppIcon,
51+
FlowerSelection,
52+
FlowerIcon
2953
},
3054
emits: {
31-
ready: () => true
55+
ready: (_ready: boolean) => true
3256
},
33-
setup() {
57+
setup(props) {
3458
const { t } = useI18n()
35-
return { t }
59+
60+
// window already defined?
61+
const definedFlowers = props.action.windowSelection ? props.navigationState.botPersistence.definedWindows.getDefinedWindow(props.action.windowSelection) : undefined
62+
const selectedFlowers = ref(definedFlowers ?? [])
63+
const managedByApp = (definedFlowers != undefined)
64+
65+
return { t, selectedFlowers, managedByApp }
3666
},
3767
props: {
3868
action: {
@@ -48,13 +78,47 @@ export default defineComponent({
4878
required: false
4979
}
5080
},
81+
data() {
82+
return {
83+
done: false
84+
}
85+
},
5186
computed: {
5287
iconName(): string {
5388
return `price-${this.action.windowSelection?.toLocaleLowerCase()}`
89+
},
90+
flowerCount() : number {
91+
return this.action.windowSelection ? getWindowSelectionFloorCount(this.action.windowSelection) : 0
92+
}
93+
},
94+
methods: {
95+
windowIsDefined() : void {
96+
if (this.action.windowSelection) {
97+
this.navigationState.botPersistence.definedWindows.setDefinedWindow(this.action.windowSelection, this.selectedFlowers)
98+
}
99+
this.doIncreasePrices()
100+
},
101+
windowIsUndefined() : void {
102+
if (this.action.priceSelection == PriceSelection.MOST_EXPENSIVE) {
103+
this.selectedFlowers = [this.navigationState.marketPrices.getMostExpensiveFlower()]
104+
}
105+
else {
106+
this.selectedFlowers = [this.navigationState.marketPrices.getCheapestFlower()]
107+
}
108+
this.doIncreasePrices()
109+
},
110+
doIncreasePrices() : void {
111+
for (const flower of this.selectedFlowers) {
112+
this.navigationState.marketPrices.increase(flower)
113+
}
114+
this.done = true
115+
this.$emit('ready', true)
54116
}
55117
},
56118
mounted() {
57-
this.$emit('ready')
119+
if (this.managedByApp) {
120+
this.$emit('ready', true)
121+
}
58122
}
59123
})
60124
</script>

src/components/round/botAction/ActionSold.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineComponent({
2828
AppIcon
2929
},
3030
emits: {
31-
ready: () => true
31+
ready: (_ready: boolean) => true
3232
},
3333
setup() {
3434
const { t } = useI18n()
@@ -49,7 +49,7 @@ export default defineComponent({
4949
}
5050
},
5151
mounted() {
52-
this.$emit('ready')
52+
this.$emit('ready', true)
5353
}
5454
})
5555
</script>

src/components/round/botAction/ActionVp5.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineComponent({
2828
AppIcon
2929
},
3030
emits: {
31-
ready: () => true
31+
ready: (_ready: boolean) => true
3232
},
3333
setup() {
3434
const { t } = useI18n()
@@ -49,7 +49,7 @@ export default defineComponent({
4949
}
5050
},
5151
mounted() {
52-
this.$emit('ready')
52+
this.$emit('ready', true)
5353
}
5454
})
5555
</script>

src/components/round/botAction/ActionWindowBox.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineComponent({
2828
AppIcon
2929
},
3030
emits: {
31-
ready: () => true
31+
ready: (_ready: boolean) => true
3232
},
3333
setup() {
3434
const { t } = useI18n()
@@ -49,7 +49,7 @@ export default defineComponent({
4949
}
5050
},
5151
mounted() {
52-
this.$emit('ready')
52+
this.$emit('ready', true)
5353
}
5454
})
5555
</script>

0 commit comments

Comments
 (0)