2026-10-28 16:57:44 +00:00
|
|
|
|
<script setup lang="ts">
|
2026-10-28 20:18:57 +00:00
|
|
|
|
import type { Building, BuildingType } from '~/types/game'
|
2026-10-28 16:57:44 +00:00
|
|
|
|
|
2026-10-28 20:18:57 +00:00
|
|
|
|
const props = defineProps<{
|
2026-10-28 16:57:44 +00:00
|
|
|
|
buildings: Building[]
|
|
|
|
|
|
busy: boolean
|
|
|
|
|
|
}>()
|
|
|
|
|
|
const emit = defineEmits<{
|
2026-10-28 18:54:29 +00:00
|
|
|
|
select: [buildingId: number]
|
2026-10-28 16:57:44 +00:00
|
|
|
|
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-11-03 08:56:40 +00:00
|
|
|
|
// Who works where: building and upgrading live in the construction table above. Copies are
|
|
|
|
|
|
// named in the server's rank, like everywhere else ("Storage, copy 2").
|
2026-10-28 20:18:57 +00:00
|
|
|
|
const named = computed(() => {
|
2026-11-03 08:56:40 +00:00
|
|
|
|
const byType = new Map<BuildingType, Building[]>()
|
|
|
|
|
|
for (const b of props.buildings) byType.set(b.type, [...(byType.get(b.type) ?? []), b])
|
|
|
|
|
|
const rank = new Map<number, number>()
|
|
|
|
|
|
for (const list of byType.values()) ranked(list).forEach((b, i) => rank.set(b.id, i))
|
2026-10-28 20:18:57 +00:00
|
|
|
|
return props.buildings.map((b) => {
|
2026-11-03 08:56:40 +00:00
|
|
|
|
const n = rank.get(b.id) ?? 0
|
|
|
|
|
|
const name = t(`buildings.${b.type}`)
|
|
|
|
|
|
return { b, name: n > 0 ? t('village.copy.name', { name, n: n + 1 }) : name }
|
2026-10-28 20:18:57 +00:00
|
|
|
|
})
|
|
|
|
|
|
})
|
2026-10-28 16:57:44 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-10-28 20:18:57 +00:00
|
|
|
|
<section class="panel overflow-hidden">
|
2026-10-28 18:04:21 +00:00
|
|
|
|
<div class="panel-head">
|
|
|
|
|
|
<h2 class="panel-title">{{ $t('village.buildings.title') }}</h2>
|
2026-10-28 19:22:53 +00:00
|
|
|
|
<span class="badge badge-plain">{{ buildings.length }}</span>
|
2026-10-28 18:04:21 +00:00
|
|
|
|
</div>
|
2026-10-28 20:18:57 +00:00
|
|
|
|
<div class="overflow-x-auto">
|
|
|
|
|
|
<table class="w-full min-w-[34rem] border-collapse text-sm">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr class="border-b-2 border-wood-700 bg-parchment-100 text-left text-xs font-semibold text-ink-700">
|
|
|
|
|
|
<th class="px-3 py-1.5">{{ $t('village.buildings.type') }}</th>
|
|
|
|
|
|
<th class="px-2 py-1.5 text-right">{{ $t('village.buildings.level') }}</th>
|
|
|
|
|
|
<th class="w-40 px-2 py-1.5">{{ $t('village.buildings.workers') }}</th>
|
|
|
|
|
|
<th class="px-2 py-1.5">{{ $t('village.buildings.output') }}</th>
|
|
|
|
|
|
<th class="px-3 py-1.5 text-right">{{ $t('village.buildings.priority') }}</th>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<tr v-for="{ b, name } in named" :key="b.id" class="border-b border-parchment-300 last:border-b-0 even:bg-parchment-100">
|
|
|
|
|
|
<td class="px-3 py-1">
|
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
|
<IconBuildingTile :type="b.type" class="size-7" />
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="truncate text-left font-semibold hover:text-blood-700 hover:underline"
|
|
|
|
|
|
:title="$t('village.buildings.show')"
|
|
|
|
|
|
@click="emit('select', b.id)"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ name }}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td class="px-2 py-1 text-right font-semibold tabular-nums">{{ b.level }}</td>
|
|
|
|
|
|
<td class="px-2 py-1">
|
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
|
<span class="w-12 shrink-0 text-xs tabular-nums">{{ b.workers.assigned }}/{{ b.workers.required }}</span>
|
|
|
|
|
|
<UiBar :value="b.staffing" :tone="b.staffing < 1 ? 'rose' : 'emerald'" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td class="px-2 py-1">
|
|
|
|
|
|
<span v-if="b.production" class="flex items-center gap-1 tabular-nums whitespace-nowrap">
|
|
|
|
|
|
<IconResource :resource="b.production.resource" class="size-4" />
|
|
|
|
|
|
{{ $t('village.resources.per_hour', { rate: formatRate(b.production.per_hour) }) }}
|
2026-10-28 18:04:21 +00:00
|
|
|
|
</span>
|
2026-10-28 20:18:57 +00:00
|
|
|
|
<span v-else class="text-ink-400">–</span>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td class="px-3 py-1 text-right">
|
|
|
|
|
|
<div class="inline-flex items-center rounded-sm border border-wood-600 bg-parchment-50">
|
|
|
|
|
|
<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>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
2026-10-28 16:57:44 +00:00
|
|
|
|
</section>
|
|
|
|
|
|
</template>
|