53 lines
1.5 KiB
Vue
53 lines
1.5 KiB
Vue
|
|
<script setup lang="ts">
|
||
|
|
import type { BuildingType } from '~/types/game'
|
||
|
|
|
||
|
|
const route = useRoute()
|
||
|
|
const v = useVillage(Number(route.params.id))
|
||
|
|
const { village, resources, error, busy } = v
|
||
|
|
|
||
|
|
/** Grid cell the next new building goes to; null lets the server pick. */
|
||
|
|
const selected = ref<{ x: number; y: number } | null>(null)
|
||
|
|
|
||
|
|
v.refresh()
|
||
|
|
|
||
|
|
async function build(type: BuildingType) {
|
||
|
|
await v.build(type, selected.value)
|
||
|
|
if (!error.value) selected.value = null
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<template>
|
||
|
|
<section v-if="village && resources">
|
||
|
|
<h1>{{ village.name }} ({{ village.x }}|{{ village.y }})</h1>
|
||
|
|
<p v-if="error" role="alert">{{ error }}</p>
|
||
|
|
|
||
|
|
<VillageResourceBar :village="village" :resources="resources" />
|
||
|
|
<VillagePopulationPanel :population="village.population" />
|
||
|
|
<VillageBuildQueue
|
||
|
|
:queue="village.queue"
|
||
|
|
:builders="village.builders"
|
||
|
|
:seconds-until="v.secondsUntil"
|
||
|
|
:busy="busy"
|
||
|
|
@cancel="v.cancel"
|
||
|
|
/>
|
||
|
|
<VillageGrid v-model:selected="selected" :village="village" />
|
||
|
|
<VillageBuildForm
|
||
|
|
:options="village.buildable"
|
||
|
|
:selected="selected"
|
||
|
|
:can-afford="v.canAfford"
|
||
|
|
:busy="busy"
|
||
|
|
@build="build"
|
||
|
|
/>
|
||
|
|
<VillageBuildingTable
|
||
|
|
:buildings="village.buildings"
|
||
|
|
:can-afford="v.canAfford"
|
||
|
|
:busy="busy"
|
||
|
|
@upgrade="v.upgrade"
|
||
|
|
@demolish="v.demolish"
|
||
|
|
@priority="v.setPriority"
|
||
|
|
/>
|
||
|
|
</section>
|
||
|
|
<p v-else-if="error" role="alert">{{ error }}</p>
|
||
|
|
<p v-else>{{ $t('common.loading') }}</p>
|
||
|
|
</template>
|