2026-10-28 21:14:56 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { BuildOption, BuildingType, Cost, Resources } from '~/types/game'
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
option: BuildOption
|
|
|
|
|
resources: Resources
|
|
|
|
|
canAfford: (cost: Cost) => boolean
|
|
|
|
|
busy: boolean
|
|
|
|
|
/** One of this type already stands; this plot is for another. */
|
|
|
|
|
another: boolean
|
|
|
|
|
/** The headquarters screen with every building. */
|
|
|
|
|
allLink: string
|
|
|
|
|
}>()
|
|
|
|
|
const emit = defineEmits<{ build: [type: BuildingType]; close: [] }>()
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
/** Why it can't be built now, or '' when the button shows. */
|
|
|
|
|
const reason = computed(() => {
|
|
|
|
|
if (props.option.blocked) return t(`village.blocked.${props.option.blocked}`)
|
|
|
|
|
if (!props.canAfford(props.option.cost)) return t('village.blocked.resources')
|
|
|
|
|
return ''
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<!-- An empty plot picked in the village: what would stand there, and building it. -->
|
|
|
|
|
<template>
|
|
|
|
|
<section class="panel" :aria-label="$t(`buildings.${option.type}`)">
|
|
|
|
|
<div class="flex items-center gap-3 border-b-2 border-wood-700 bg-parchment-200 px-4 py-3">
|
feat: building portraits, screen headers and a livelier village: shadows, smoke, walkers, a pond
Each building screen opens with the building drawn as it stands, its level and what it
does; the HQ list and the building cards show the same portraits. In the village,
buildings and trees cast flat shadows, chimneys, forges and kilns smoke, villagers walk
the roads to the zones they work in (more where more work), and a pond lies in the
meadow. Motion stops for players who prefer reduced motion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:46:15 +00:00
|
|
|
<VillagePortraitTile :type="option.type" :level="1" class="size-14" />
|
2026-10-28 21:14:56 +00:00
|
|
|
<div class="min-w-0 flex-1">
|
2026-10-29 00:26:08 +00:00
|
|
|
<h2 class="truncate font-display text-base font-bold text-wood-950">{{ $t(`buildings.${option.type}`) }}</h2>
|
2026-10-28 21:14:56 +00:00
|
|
|
<p class="text-xs text-ink-500">
|
|
|
|
|
{{ another ? $t('village.plot.another') : $t('village.build.not_built') }}
|
|
|
|
|
<template v-if="option.space"> · {{ $t('village.build.space', { space: option.space }) }}</template>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<button type="button" class="btn btn-ghost p-1.5" :aria-label="$t('common.close')" :title="$t('common.close')" @click="emit('close')">
|
|
|
|
|
<IconUi name="close" class="size-4" />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="space-y-3 px-4 py-3">
|
|
|
|
|
<div v-if="option.requires.length" class="space-y-1 text-sm">
|
|
|
|
|
<p class="text-xs text-ink-500">{{ $t('village.build.requires') }}</p>
|
|
|
|
|
<p v-for="r in option.requires" :key="r.type" class="flex items-center gap-1.5">
|
|
|
|
|
<IconBuildingTile :type="r.type" class="size-5" />
|
|
|
|
|
{{ $t('village.build.requirement', { type: $t(`buildings.${r.type}`), level: r.level }) }}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="space-y-1.5 rounded-sm border border-wood-600/50 bg-parchment-100 p-3">
|
|
|
|
|
<div class="flex items-center justify-between gap-2 text-xs text-ink-500">
|
|
|
|
|
<UiCost :cost="option.cost" :have="resources" />
|
|
|
|
|
<span class="flex items-center gap-1 tabular-nums">
|
|
|
|
|
<IconUi name="clock" class="size-3" />
|
|
|
|
|
{{ formatDuration(option.seconds) }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<button v-if="!reason" type="button" class="btn btn-primary w-full" :disabled="busy" @click="emit('build', option.type)">
|
|
|
|
|
<IconUi name="hammer" class="size-3.5" />
|
|
|
|
|
{{ $t('village.build.submit') }}
|
|
|
|
|
</button>
|
|
|
|
|
<p v-else class="text-center text-xs font-semibold text-blood-700">{{ reason }}</p>
|
|
|
|
|
</div>
|
2026-10-29 13:09:03 +00:00
|
|
|
<NuxtLink :to="allLink" class="btn btn-outline w-full">{{ $t('village.plot.all') }}</NuxtLink>
|
2026-10-28 21:14:56 +00:00
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|