2026-10-29 13:38:34 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const v = useVillageContext()
|
|
|
|
|
const village = computed(() => v.village.value!)
|
|
|
|
|
const resources = computed(() => v.resources.value!)
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
const building = computed(() => village.value.buildings.find((b) => b.id === Number(route.params.bid)) ?? null)
|
|
|
|
|
// Torn down or taken away: back to the village.
|
|
|
|
|
watch(building, (b) => {
|
|
|
|
|
if (!b) navigateTo(`/village/${route.params.id}`)
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<!-- Inside one building: the close-up, what it does and what can be done with it. -->
|
|
|
|
|
<template>
|
2026-10-30 11:11:15 +00:00
|
|
|
<VillageScreenLayout v-if="building">
|
|
|
|
|
<template #side>
|
|
|
|
|
<VillageBuildingHeader
|
|
|
|
|
:building="building"
|
|
|
|
|
:title="buildingName(village, building, t)"
|
|
|
|
|
:resources="resources"
|
|
|
|
|
:can-afford="v.canAfford"
|
|
|
|
|
:busy="v.busy.value"
|
|
|
|
|
@upgrade="v.upgrade"
|
|
|
|
|
@demolish="v.demolish"
|
|
|
|
|
@priority="v.setPriority"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- Every building of this type, and one more: the headquarters list for just this type. -->
|
|
|
|
|
<VillageBuildForm
|
|
|
|
|
:options="village.buildable.filter((o) => o.type === building!.type)"
|
|
|
|
|
:buildings="village.buildings.filter((b) => b.type === building!.type)"
|
|
|
|
|
:space="village.space"
|
2026-10-29 13:38:34 +00:00
|
|
|
:resources="resources"
|
|
|
|
|
:can-afford="v.canAfford"
|
|
|
|
|
:busy="v.busy.value"
|
2026-10-30 11:11:15 +00:00
|
|
|
@build="v.build"
|
2026-10-29 13:38:34 +00:00
|
|
|
@upgrade="v.upgrade"
|
|
|
|
|
@demolish="v.demolish"
|
2026-10-30 11:11:15 +00:00
|
|
|
@select="(id: number) => navigateTo(`/village/${route.params.id}/building/${id}`)"
|
2026-10-29 13:38:34 +00:00
|
|
|
/>
|
2026-10-30 11:11:15 +00:00
|
|
|
</VillageScreenLayout>
|
2026-10-29 13:38:34 +00:00
|
|
|
</template>
|