2026-10-28 16:57:44 +00:00
|
|
|
<script setup lang="ts">
|
2026-10-28 18:04:21 +00:00
|
|
|
import type { BuildOption, BuildingType, Cost, Resources } from '~/types/game'
|
2026-10-28 16:57:44 +00:00
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
options: BuildOption[]
|
2026-10-28 18:54:29 +00:00
|
|
|
space: { used: number; max: number }
|
2026-10-28 18:04:21 +00:00
|
|
|
resources: Resources
|
2026-10-28 16:57:44 +00:00
|
|
|
canAfford: (cost: Cost) => boolean
|
|
|
|
|
busy: boolean
|
|
|
|
|
}>()
|
2026-10-28 18:54:29 +00:00
|
|
|
const emit = defineEmits<{ build: [type: BuildingType] }>()
|
2026-10-28 16:57:44 +00:00
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
function status(o: BuildOption) {
|
|
|
|
|
if (o.blocked) return t(`village.blocked.${o.blocked}`)
|
|
|
|
|
if (!props.canAfford(o.cost)) return t('village.blocked.resources')
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-10-28 18:04:21 +00:00
|
|
|
<section class="panel">
|
|
|
|
|
<div class="panel-head">
|
|
|
|
|
<h2 class="panel-title">{{ $t('village.build.title') }}</h2>
|
2026-10-28 19:22:53 +00:00
|
|
|
<span class="badge badge-plain">
|
2026-10-28 18:54:29 +00:00
|
|
|
{{ $t('village.build.free_space', { free: space.max - space.used }) }}
|
|
|
|
|
</span>
|
2026-10-28 18:04:21 +00:00
|
|
|
</div>
|
2026-10-28 18:54:29 +00:00
|
|
|
<div class="panel-body grid gap-3 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
|
2026-10-28 18:04:21 +00:00
|
|
|
<article
|
|
|
|
|
v-for="o in options"
|
|
|
|
|
:key="o.type"
|
2026-10-28 19:22:53 +00:00
|
|
|
class="flex flex-col gap-2.5 rounded-sm border-2 border-parchment-300 bg-parchment-100 p-3"
|
2026-10-28 18:04:21 +00:00
|
|
|
:class="o.blocked ? 'opacity-60' : ''"
|
|
|
|
|
>
|
|
|
|
|
<div class="flex items-center gap-2.5">
|
|
|
|
|
<IconBuildingTile :type="o.type" class="size-10" />
|
|
|
|
|
<div class="min-w-0">
|
|
|
|
|
<h3 class="truncate font-medium">{{ $t(`buildings.${o.type}`) }}</h3>
|
|
|
|
|
<p class="flex flex-wrap items-center gap-x-1.5 text-xs text-ink-500">
|
|
|
|
|
<span class="whitespace-nowrap">
|
2026-10-28 18:54:29 +00:00
|
|
|
{{ o.space ? $t('village.build.space', { space: o.space }) : $t('village.build.surrounds') }}
|
2026-10-28 18:04:21 +00:00
|
|
|
</span>
|
|
|
|
|
<span class="flex items-center gap-1 whitespace-nowrap tabular-nums">
|
|
|
|
|
<IconUi name="clock" class="size-3" />
|
|
|
|
|
{{ formatDuration(o.seconds) }}
|
|
|
|
|
</span>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<UiCost :cost="o.cost" :have="resources" />
|
|
|
|
|
<div class="mt-auto flex items-center justify-between gap-2">
|
2026-10-28 19:22:53 +00:00
|
|
|
<span class="text-xs font-semibold text-blood-700">{{ status(o) }}</span>
|
2026-10-28 18:04:21 +00:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="btn btn-primary"
|
|
|
|
|
:disabled="busy || !!o.blocked || !canAfford(o.cost)"
|
|
|
|
|
@click="emit('build', o.type)"
|
|
|
|
|
>
|
|
|
|
|
<IconUi name="hammer" class="size-3.5" />
|
|
|
|
|
{{ $t('village.build.submit') }}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</article>
|
|
|
|
|
</div>
|
2026-10-28 16:57:44 +00:00
|
|
|
</section>
|
|
|
|
|
</template>
|