2026-10-28 21:14:56 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { BuildingType } from '~/types/game'
|
|
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const v = useVillageContext()
|
|
|
|
|
const village = computed(() => v.village.value!)
|
|
|
|
|
const resources = computed(() => v.resources.value!)
|
|
|
|
|
const base = `/village/${route.params.id}`
|
|
|
|
|
|
2026-10-29 13:38:34 +00:00
|
|
|
// The village fills the screen behind (GameVillageFrame); buildings open their own
|
|
|
|
|
// screens. Here is only the build card of an empty plot picked in the village.
|
|
|
|
|
// An old `?b=` link opens that building's screen.
|
|
|
|
|
const linked = village.value.buildings.find((b) => b.id === Number(route.query.b))
|
|
|
|
|
if (linked) navigateTo(buildingRoute(village.value, linked), { replace: true })
|
2026-10-29 09:56:52 +00:00
|
|
|
|
2026-10-29 13:38:34 +00:00
|
|
|
const { plot } = useVillageSelection()
|
2026-10-28 21:14:56 +00:00
|
|
|
const plotOption = computed(() => village.value.buildable.find((o) => o.type === plot.value) ?? null)
|
|
|
|
|
|
|
|
|
|
async function build(type: BuildingType) {
|
|
|
|
|
await v.build(type)
|
|
|
|
|
if (!v.error.value) plot.value = null
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-10-29 09:56:52 +00:00
|
|
|
<VillagePlotCard
|
2026-10-29 13:38:34 +00:00
|
|
|
v-if="plotOption"
|
2026-10-29 09:56:52 +00:00
|
|
|
:option="plotOption"
|
|
|
|
|
:resources="resources"
|
|
|
|
|
:can-afford="v.canAfford"
|
|
|
|
|
:busy="v.busy.value"
|
|
|
|
|
:another="village.buildings.some((b) => b.type === plotOption!.type)"
|
|
|
|
|
:all-link="`${base}/build`"
|
|
|
|
|
@build="build"
|
|
|
|
|
@close="plot = null"
|
|
|
|
|
/>
|
2026-10-28 21:14:56 +00:00
|
|
|
</template>
|