2026-10-28 16:57:44 +00:00
|
|
|
|
<script setup lang="ts">
|
2026-10-28 18:04:21 +00:00
|
|
|
|
import type { Building, Cost, Resources } from '~/types/game'
|
2026-10-28 16:57:44 +00:00
|
|
|
|
|
|
|
|
|
|
defineProps<{
|
|
|
|
|
|
buildings: Building[]
|
2026-10-28 18:04:21 +00:00
|
|
|
|
resources: Resources
|
2026-10-28 16:57:44 +00:00
|
|
|
|
canAfford: (cost: Cost) => boolean
|
|
|
|
|
|
busy: boolean
|
|
|
|
|
|
}>()
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
|
upgrade: [buildingId: number]
|
|
|
|
|
|
demolish: [buildingId: number]
|
|
|
|
|
|
priority: [buildingId: number, priority: number]
|
|
|
|
|
|
}>()
|
2026-10-28 18:04:21 +00:00
|
|
|
|
const { t } = useI18n()
|
2026-10-28 16:57:44 +00:00
|
|
|
|
|
2026-10-28 18:04:21 +00:00
|
|
|
|
const demolishTitle = (b: Building) =>
|
|
|
|
|
|
b.demolish ? `${t('village.buildings.refund')} ${formatCost(b.demolish.refund)}, ${formatDuration(b.demolish.seconds)}` : ''
|
2026-10-28 16:57:44 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-10-28 18:04:21 +00:00
|
|
|
|
<section class="panel">
|
|
|
|
|
|
<div class="panel-head">
|
|
|
|
|
|
<h2 class="panel-title">{{ $t('village.buildings.title') }}</h2>
|
|
|
|
|
|
<span class="badge bg-parchment-200 text-ink-700">{{ buildings.length }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<ul class="divide-y divide-parchment-200">
|
|
|
|
|
|
<li
|
|
|
|
|
|
v-for="b in buildings"
|
|
|
|
|
|
:key="b.id"
|
|
|
|
|
|
class="grid gap-3 px-4 py-3 md:grid-cols-[minmax(0,13rem)_minmax(0,1fr)_19rem] md:items-center"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="flex min-w-0 items-center gap-3">
|
|
|
|
|
|
<IconBuildingTile :type="b.type" class="size-11" />
|
|
|
|
|
|
<div class="min-w-0">
|
|
|
|
|
|
<p class="truncate font-medium">{{ $t(`buildings.${b.type}`) }}</p>
|
|
|
|
|
|
<p class="text-xs text-ink-500">
|
|
|
|
|
|
{{ $t('village.buildings.level_n', { level: b.level }) }}
|
|
|
|
|
|
<template v-if="b.footprint[0]"> · {{ b.x }}|{{ b.y }}</template>
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="grid grid-cols-3 gap-3 text-sm">
|
|
|
|
|
|
<div class="min-w-0">
|
|
|
|
|
|
<p class="text-xs text-ink-500">{{ $t('village.buildings.workers') }}</p>
|
|
|
|
|
|
<p class="tabular-nums">{{ b.workers.assigned }}/{{ b.workers.required }}</p>
|
|
|
|
|
|
<UiBar class="mt-1" :value="b.staffing" :tone="b.staffing < 1 ? 'rose' : 'emerald'" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="min-w-0">
|
|
|
|
|
|
<p class="text-xs text-ink-500">{{ $t('village.buildings.output') }}</p>
|
|
|
|
|
|
<p v-if="b.production" class="flex items-center gap-1 tabular-nums">
|
|
|
|
|
|
<IconResource :resource="b.production.resource" class="size-4" />
|
2026-10-28 16:57:44 +00:00
|
|
|
|
{{ $t('village.resources.per_hour', { rate: formatRate(b.production.per_hour) }) }}
|
2026-10-28 18:04:21 +00:00
|
|
|
|
</p>
|
|
|
|
|
|
<p v-else class="text-ink-400">–</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="min-w-0">
|
|
|
|
|
|
<p class="text-xs text-ink-500">{{ $t('village.buildings.priority') }}</p>
|
|
|
|
|
|
<div class="mt-0.5 inline-flex items-center rounded-lg ring-1 ring-parchment-300">
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="btn btn-ghost rounded-r-none p-1"
|
|
|
|
|
|
:aria-label="$t('village.buildings.priority_down')"
|
|
|
|
|
|
:disabled="busy || b.priority <= 0"
|
|
|
|
|
|
@click="emit('priority', b.id, b.priority - 1)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<IconUi name="minus" class="size-3.5" />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<span class="w-6 text-center font-semibold tabular-nums">{{ b.priority }}</span>
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="btn btn-ghost rounded-l-none p-1"
|
|
|
|
|
|
:aria-label="$t('village.buildings.priority_up')"
|
|
|
|
|
|
:disabled="busy || b.priority >= 9"
|
|
|
|
|
|
@click="emit('priority', b.id, b.priority + 1)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<IconUi name="plus" class="size-3.5" />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-wrap items-center gap-x-3 gap-y-2 md:justify-end">
|
|
|
|
|
|
<div v-if="b.upgrade" class="flex flex-col items-start gap-1 md:items-end">
|
2026-10-28 16:57:44 +00:00
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
2026-10-28 18:04:21 +00:00
|
|
|
|
class="btn btn-primary"
|
2026-10-28 16:57:44 +00:00
|
|
|
|
:disabled="busy || !canAfford(b.upgrade.cost)"
|
|
|
|
|
|
@click="emit('upgrade', b.id)"
|
|
|
|
|
|
>
|
2026-10-28 18:04:21 +00:00
|
|
|
|
<IconUi name="up" class="size-3.5" />
|
2026-10-28 16:57:44 +00:00
|
|
|
|
{{ $t('village.buildings.upgrade', { level: b.upgrade.target_level }) }}
|
|
|
|
|
|
</button>
|
2026-10-28 18:04:21 +00:00
|
|
|
|
<span class="flex items-center gap-2 text-xs text-ink-500">
|
|
|
|
|
|
<UiCost :cost="b.upgrade.cost" :have="resources" />
|
|
|
|
|
|
<span class="flex items-center gap-1 tabular-nums">
|
|
|
|
|
|
<IconUi name="clock" class="size-3" />
|
|
|
|
|
|
{{ formatDuration(b.upgrade.seconds) }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button
|
|
|
|
|
|
v-if="b.demolish"
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="btn btn-danger"
|
|
|
|
|
|
:title="demolishTitle(b)"
|
|
|
|
|
|
:disabled="busy"
|
|
|
|
|
|
@click="emit('demolish', b.id)"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ $t('village.buildings.demolish') }}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
2026-10-28 16:57:44 +00:00
|
|
|
|
</section>
|
|
|
|
|
|
</template>
|