2026-10-28 23:38:54 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { Resource } from '~/types/game'
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
resource: Resource
|
|
|
|
|
amount: number
|
|
|
|
|
cap: number
|
|
|
|
|
/** Per hour; food can be negative. */
|
|
|
|
|
rate: number
|
|
|
|
|
}>()
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
const share = computed(() => Math.max(0, Math.min(1, props.amount / props.cap)))
|
|
|
|
|
const full = computed(() => props.amount >= props.cap)
|
|
|
|
|
/** Seconds until the storage is full at this rate; null when it won't fill. */
|
|
|
|
|
const fullIn = computed(() => (props.rate > 0 && !full.value ? ((props.cap - props.amount) / props.rate) * 3600 : null))
|
|
|
|
|
const title = computed(() =>
|
|
|
|
|
[
|
|
|
|
|
`${t(`resources.${props.resource}`)}: ${formatAmount(props.amount)} / ${props.cap}`,
|
|
|
|
|
t('village.resources.per_hour', { rate: formatRate(props.rate) }),
|
|
|
|
|
full.value ? t('village.resources.full') : fullIn.value !== null ? t('village.resources.full_in', { time: formatDuration(fullIn.value) }) : null,
|
|
|
|
|
]
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
.join(' · '),
|
|
|
|
|
)
|
|
|
|
|
</script>
|
|
|
|
|
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
<!--
|
|
|
|
|
One resource in the village row, everything about it side by side: the amount against
|
|
|
|
|
the storage limit, what comes in per hour, and a bar of how full the storage is.
|
|
|
|
|
-->
|
2026-10-28 23:38:54 +00:00
|
|
|
<template>
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
<span class="inline-flex min-w-0 items-center gap-1 sm:gap-1.5" :title="title">
|
|
|
|
|
<IconResource :resource="resource" class="size-4 shrink-0 sm:size-5" />
|
|
|
|
|
<span class="flex min-w-0 flex-col leading-tight">
|
|
|
|
|
<span class="whitespace-nowrap tabular-nums">
|
|
|
|
|
<span class="font-semibold" :class="full ? 'text-blood-700' : 'text-ink-900'">{{ formatAmount(amount) }}</span>
|
|
|
|
|
<span class="hidden text-xs text-ink-500 sm:inline">/{{ cap }}</span>
|
2026-10-28 23:38:54 +00:00
|
|
|
</span>
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
<span class="text-xs whitespace-nowrap tabular-nums" :class="full || rate < 0 ? 'font-semibold text-blood-700' : 'text-moss-700'">
|
|
|
|
|
{{ full ? $t('village.resources.full_short') : $t('village.resources.per_hour', { rate: formatRate(rate) }) }}
|
|
|
|
|
</span>
|
|
|
|
|
<span class="mt-0.5 h-1 w-full min-w-8 bg-parchment-300" aria-hidden="true">
|
2026-10-28 23:38:54 +00:00
|
|
|
<span class="block h-full" :class="full ? 'bg-blood-700' : share > 0.85 ? 'bg-gold-500' : 'bg-moss-600'" :style="{ width: `${share * 100}%` }" />
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|