30 lines
903 B
Vue
30 lines
903 B
Vue
|
|
<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>
|
||
|
|
<div v-if="building" class="p-2.5">
|
||
|
|
<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"
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
</template>
|