+ {{ $t('village.build.position') }}: + {{ $t('village.build.at_cell') }} ({{ selected.x }}|{{ selected.y }}) + {{ $t('village.build.auto') }} +
+| {{ $t('village.build.type') }} | +{{ $t('village.build.size') }} | +{{ $t('village.build.cost') }} ({{ $t('resources.wood') }} / {{ $t('resources.clay') }} / {{ $t('resources.iron') }}) | +{{ $t('village.build.time') }} | +{{ $t('village.build.status') }} | ++ |
|---|---|---|---|---|---|
| {{ $t(`buildings.${o.type}`) }} | +{{ o.footprint[0] }}×{{ o.footprint[1] }} | +{{ formatCost(o.cost) }} | +{{ formatDuration(o.seconds) }} | +{{ status(o) }} | ++ + | +
{{ $t('village.queue.empty') }}
+| # | +{{ $t('village.queue.order') }} | +{{ $t('village.queue.builder') }} | +{{ $t('village.queue.remaining') }} | ++ |
|---|---|---|---|---|
| {{ o.position }} | +{{ describe(o) }} | +{{ o.builder ?? '–' }} | +{{ o.finishes_at ? formatDuration(secondsUntil(o.finishes_at)) : $t('village.queue.waiting') }} | ++ + | +
| {{ $t('village.buildings.type') }} | +{{ $t('village.buildings.level') }} | +{{ $t('village.buildings.position') }} | +{{ $t('village.buildings.size') }} | +{{ $t('village.buildings.workers') }} | +{{ $t('village.buildings.staffing') }} | +{{ $t('village.buildings.output') }} | +{{ $t('village.buildings.priority') }} | +{{ $t('village.buildings.actions') }} | +
|---|---|---|---|---|---|---|---|---|
| {{ $t(`buildings.${b.type}`) }} | +{{ b.level }} | +{{ b.footprint[0] ? `${b.x}|${b.y}` : '–' }} | +{{ b.footprint[0] }}×{{ b.footprint[1] }} | +{{ b.workers.assigned }}/{{ b.workers.required }} | +{{ Math.round(b.staffing * 100) }}% | ++ + {{ $t(`resources.${b.production.resource}`) }} + {{ $t('village.resources.per_hour', { rate: formatRate(b.production.per_hour) }) }} + + – + | ++ + | ++ + + | +
{{ $t('village.grid.hint') }}
+| + {{ $t(`buildings.${cell.item.type}`) }} + ({{ $t('village.grid.planned') }}) + {{ cell.item.level }} + | ++ {{ cell.x }}|{{ cell.y }} + | + +
| {{ $t('village.population.food_budget') }} | +{{ $t('village.population.food_per_hour', { value: population.food_budget }) }} | +
|---|---|
| {{ $t('village.population.upkeep') }} | +{{ $t('village.population.food_per_hour', { value: population.upkeep }) }} | +
| {{ $t('village.population.villagers') }} | +{{ population.villagers }} | +
| {{ $t('village.population.workers') }} | +{{ population.workers }} | +
| {{ $t('village.population.idle') }} | +{{ population.villagers - population.workers }} | +
| {{ $t('village.population.soldiers') }} | +{{ population.soldiers }} | +
| {{ $t(`resources.${r}`) }} | +{{ $t('village.resources.cap') }} | +
|---|---|
| + {{ formatAmount(resources[r]) }} + ({{ $t('village.resources.per_hour', { rate: formatRate(village.rates[r]) }) }}) + | +{{ village.storage_cap }} | +
{{ error }}
+ +{{ error }}
+{{ $t('common.loading') }}
+ diff --git a/app/utils/format.ts b/app/utils/format.ts new file mode 100644 index 0000000..4e63b4e --- /dev/null +++ b/app/utils/format.ts @@ -0,0 +1,16 @@ +import type { Cost } from '~/types/game' + +const pad = (n: number) => String(n).padStart(2, '0') + +/** 3725 → "1:02:05" */ +export function formatDuration(totalSeconds: number) { + const s = Math.max(0, Math.round(totalSeconds)) + return `${Math.floor(s / 3600)}:${pad(Math.floor((s % 3600) / 60))}:${pad(s % 60)}` +} + +export const formatAmount = (n: number) => String(Math.floor(n)) + +/** 12.5 → "+12.5", -3 → "-3" */ +export const formatRate = (n: number) => `${n >= 0 ? '+' : ''}${Math.round(n * 10) / 10}` + +export const formatCost = (cost: Cost) => `${cost.wood} / ${cost.clay} / ${cost.iron}`