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[]
|
|
|
|
|
|
selected: { x: number; y: number } | null
|
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:04:21 +00:00
|
|
|
|
const emit = defineEmits<{ build: [type: BuildingType]; clear: [] }>()
|
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>
|
|
|
|
|
|
<div class="flex items-center gap-1.5 text-sm">
|
|
|
|
|
|
<span class="text-ink-500">{{ $t('village.build.position') }}</span>
|
|
|
|
|
|
<template v-if="selected">
|
|
|
|
|
|
<span class="badge bg-amber-100 text-amber-800">
|
|
|
|
|
|
<IconUi name="pin" class="size-3.5" />
|
|
|
|
|
|
{{ selected.x }}|{{ selected.y }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="btn btn-ghost p-1"
|
|
|
|
|
|
:title="$t('common.clear')"
|
|
|
|
|
|
:aria-label="$t('common.clear')"
|
|
|
|
|
|
@click="emit('clear')"
|
|
|
|
|
|
>
|
|
|
|
|
|
<IconUi name="close" class="size-3.5" />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<span v-else class="badge bg-parchment-200 text-ink-700">{{ $t('village.build.auto') }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="panel-body grid gap-3 sm:grid-cols-2 xl:grid-cols-3">
|
|
|
|
|
|
<article
|
|
|
|
|
|
v-for="o in options"
|
|
|
|
|
|
:key="o.type"
|
|
|
|
|
|
class="flex flex-col gap-2.5 rounded-lg bg-parchment-50 p-3 ring-1 ring-parchment-200"
|
|
|
|
|
|
: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">
|
|
|
|
|
|
{{ o.footprint[0] ? `${o.footprint[0]}×${o.footprint[1]}` : $t('village.build.surrounds') }}
|
|
|
|
|
|
</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">
|
|
|
|
|
|
<span class="text-xs text-rose-700">{{ status(o) }}</span>
|
|
|
|
|
|
<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>
|