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}`
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
2026-10-29 09:56:52 +00:00
|
|
|
// The village itself fills the screen behind (GameVillageFrame); here is only the card of
|
|
|
|
|
// what is picked in it, shown in the window. `?b=` opens a building's card.
|
|
|
|
|
const { selected, plot } = useVillageSelection()
|
|
|
|
|
if (Number(route.query.b)) selected.value = Number(route.query.b)
|
|
|
|
|
|
2026-10-28 21:14:56 +00:00
|
|
|
const selectedBuilding = computed(() => village.value.buildings.find((b) => b.id === selected.value) ?? null)
|
|
|
|
|
const plotOption = computed(() => village.value.buildable.find((o) => o.type === plot.value) ?? null)
|
|
|
|
|
watch(selectedBuilding, (b) => {
|
|
|
|
|
if (!b) selected.value = null
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/** Where the card of the selected building leads: its own screen, if it has one. */
|
|
|
|
|
const screenLink = computed(() => {
|
|
|
|
|
const b = selectedBuilding.value
|
|
|
|
|
if (!b) return null
|
|
|
|
|
if (b.type === 'headquarters') return { to: `${base}/build`, label: t('village.screens.build') }
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
if (b.type === 'rally_point') return { to: `${base}/rally`, label: t('village.screens.rally') }
|
2026-10-28 21:14:56 +00:00
|
|
|
if (village.value.military.some((m) => m.building_id === b.id)) {
|
|
|
|
|
return { to: { path: `${base}/recruit`, query: { at: b.id } }, label: t('village.buildings.recruit') }
|
|
|
|
|
}
|
|
|
|
|
return 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
|
|
|
<VillageBuildingCard
|
|
|
|
|
v-if="selectedBuilding"
|
|
|
|
|
:building="selectedBuilding"
|
|
|
|
|
:resources="resources"
|
|
|
|
|
:can-afford="v.canAfford"
|
|
|
|
|
:busy="v.busy.value"
|
|
|
|
|
:link="screenLink"
|
|
|
|
|
@upgrade="v.upgrade"
|
|
|
|
|
@demolish="v.demolish"
|
|
|
|
|
@priority="v.setPriority"
|
|
|
|
|
@close="selected = null"
|
|
|
|
|
/>
|
|
|
|
|
<VillagePlotCard
|
|
|
|
|
v-else-if="plotOption"
|
|
|
|
|
: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>
|