78 lines
2.5 KiB
Vue
78 lines
2.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>
|
|
<div v-if="village && resources">
|
|
<VillageResourceBar class="sticky top-0 z-30" :village="village" :resources="resources" />
|
|
|
|
<div class="mx-auto max-w-6xl space-y-6 px-4 py-6">
|
|
<header class="flex flex-wrap items-end justify-between gap-2">
|
|
<div class="min-w-0">
|
|
<p class="text-xs font-medium tracking-wide text-ink-500 uppercase">{{ $t('village.title') }}</p>
|
|
<h1 class="truncate font-display text-2xl font-semibold sm:text-3xl">{{ village.name }}</h1>
|
|
</div>
|
|
<span class="badge bg-parchment-200 text-ink-700">
|
|
<IconUi name="pin" class="size-3.5" />
|
|
{{ village.x }}|{{ village.y }}
|
|
</span>
|
|
</header>
|
|
|
|
<p v-if="error" class="alert" role="alert">{{ error }}</p>
|
|
|
|
<div class="grid gap-6 lg:grid-cols-3">
|
|
<div class="space-y-6 lg:col-span-2">
|
|
<VillageGrid v-model:selected="selected" :village="village" />
|
|
<VillageBuildForm
|
|
:options="village.buildable"
|
|
:selected="selected"
|
|
:resources="resources"
|
|
:can-afford="v.canAfford"
|
|
:busy="busy"
|
|
@build="build"
|
|
@clear="selected = null"
|
|
/>
|
|
</div>
|
|
<div class="space-y-6">
|
|
<VillageBuildQueue
|
|
:queue="village.queue"
|
|
:builders="village.builders"
|
|
:seconds-until="v.secondsUntil"
|
|
:busy="busy"
|
|
@cancel="v.cancel"
|
|
/>
|
|
<VillagePopulationPanel :population="village.population" />
|
|
</div>
|
|
</div>
|
|
|
|
<VillageBuildingTable
|
|
:buildings="village.buildings"
|
|
:resources="resources"
|
|
:can-afford="v.canAfford"
|
|
:busy="busy"
|
|
@upgrade="v.upgrade"
|
|
@demolish="v.demolish"
|
|
@priority="v.setPriority"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div v-else class="mx-auto max-w-6xl px-4 py-16 text-center">
|
|
<p v-if="error" class="alert inline-block" role="alert">{{ error }}</p>
|
|
<p v-else class="text-sm text-ink-500">{{ $t('common.loading') }}</p>
|
|
</div>
|
|
</template>
|