From 4c638667e79c822f3cdfd39f535d7c1fbb000837 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Tue, 3 Nov 2026 09:56:40 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20the=20headquarters=20list=20groups=20ea?= =?UTF-8?q?ch=20building=20type:=20its=20portrait=20and=20count=20once,=20?= =?UTF-8?q?the=20instances=20as=20sub-rows=20in=20the=20server's=20rank=20?= =?UTF-8?q?(main,=20then=20Copy=202=20=C2=B7=2050%),=20Build=20another=20a?= =?UTF-8?q?s=20the=20group's=20last=20row,=20a=20heavier=20rule=20between?= =?UTF-8?q?=20groups;=20villagers=20next=20to=20every=20cost,=20no=20sidew?= =?UTF-8?q?ays=20scroll=20on=20phones;=20copies=20are=20named=20by=20rank?= =?UTF-8?q?=20everywhere?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- app/components/village/BuildForm.vue | 289 ++++++++++++---------- app/components/village/BuildingTable.vue | 19 +- app/components/village/Recruit.vue | 8 +- app/pages/village/[id]/build.vue | 1 + app/pages/village/[id]/building/[bid].vue | 1 + app/utils/copies.ts | 8 + app/utils/screens.ts | 9 +- i18n/pages/village.ts | 2 - 8 files changed, 193 insertions(+), 144 deletions(-) diff --git a/app/components/village/BuildForm.vue b/app/components/village/BuildForm.vue index b8d903f..95bc714 100644 --- a/app/components/village/BuildForm.vue +++ b/app/components/village/BuildForm.vue @@ -8,6 +8,8 @@ const props = defineProps<{ resources: Resources canAfford: (cost: Cost) => boolean busy: boolean + /** Villagers free for a new level (`population.idle`): a villager count above it shows red. */ + idle: number /** A building type a quest points at: its rows are marked and scrolled into view. */ hint?: string | null }>() @@ -24,17 +26,21 @@ const { t } = useI18n() // the second tab; types still waiting for requirements are listed at the bottom. const tab = ref<'construct' | 'demolish'>('construct') +/** Instances per type in the server's rank: the one that works in full first, then the copies. */ const byType = computed(() => { const map = new Map() for (const b of props.buildings) map.set(b.type, [...(map.get(b.type) ?? []), b]) + for (const [type, list] of map) map.set(type, ranked(list)) return map }) -// Rows of one type form a group: its instances, then building one more of it, indented -// under them so it reads as another copy and not as something still missing. -type Row = { group: number; first: boolean } & ( - | { kind: 'upgrade'; key: string; type: BuildingType; name: string; building: Building; offer: Offer | null } - | { kind: 'build'; key: string; type: BuildingType; name: string; option: BuildOption; another: number } +// Rows of one type form a group. With two or more instances the group opens with a header +// (portrait, name, count) and the instances follow as sub-rows; building one more is the +// group's last sub-row. A type with one instance or none stays a single row. +type Row = { group: number; first: boolean; sub: boolean } & ( + | { kind: 'head'; key: string; type: BuildingType; count: number } + | { kind: 'upgrade'; key: string; type: BuildingType; building: Building; offer: Offer | null; rank: number } + | { kind: 'build'; key: string; type: BuildingType; option: BuildOption; another: boolean } ) const rows = computed(() => { @@ -43,33 +49,17 @@ const rows = computed(() => { for (const o of props.options) { if (o.blocked === 'requires') continue const instances = byType.value.get(o.type) ?? [] + const grouped = instances.length > 1 const start = out.length group++ - const numbered = instances.length > 1 || (instances.length > 0 && o.blocked !== 'max_per_village') - instances.forEach((b, i) => { - out.push({ - group, - first: false, - kind: 'upgrade', - key: `b${b.id}`, - type: b.type, - name: numbered ? t('village.build.nth', { name: t(`buildings.${b.type}`), n: i + 1 }) : t(`buildings.${b.type}`), - building: b, - offer: b.upgrade, - }) + if (grouped) out.push({ group, first: false, sub: false, kind: 'head', key: `head-${o.type}`, type: o.type, count: instances.length }) + instances.forEach((b, rank) => { + out.push({ group, first: false, sub: grouped, kind: 'upgrade', key: `b${b.id}`, type: b.type, building: b, offer: b.upgrade, rank }) }) // A unique type that already stands has nothing more to build. - if (o.blocked === 'max_per_village' && instances.length) continue - out.push({ - group, - first: false, - kind: 'build', - key: `new-${o.type}`, - type: o.type, - name: instances.length ? t('village.build.nth', { name: t(`buildings.${o.type}`), n: instances.length + 1 }) : t(`buildings.${o.type}`), - option: o, - another: instances.length ? instances.length + 1 : 0, - }) + if (!(o.blocked === 'max_per_village' && instances.length)) { + out.push({ group, first: false, sub: instances.length > 0, kind: 'build', key: `new-${o.type}`, type: o.type, option: o, another: instances.length > 0 }) + } if (out[start]) out[start]!.first = true } return out @@ -98,14 +88,14 @@ function reason(offer: Offer | null) { return '' } -const demolishable = computed(() => - props.buildings.map((b) => ({ - b, - name: (byType.value.get(b.type)?.length ?? 0) > 1 - ? t('village.build.nth', { name: t(`buildings.${b.type}`), n: byType.value.get(b.type)!.indexOf(b) + 1 }) - : t(`buildings.${b.type}`), - })), -) +/** "Storage" for the one that works in full, "Storage, copy 2" for the copies after it. */ +function nameOf(b: Building) { + const name = t(`buildings.${b.type}`) + const n = byType.value.get(b.type)?.indexOf(b) ?? 0 + return n > 0 ? t('village.copy.name', { name, n: n + 1 }) : name +} + +const demolishable = computed(() => [...byType.value.values()].flat().map((b) => ({ b, name: nameOf(b) }))) -
- +
+
- - - - - + + + + + - - + - - - + +
{{ $t('village.build.building') }}{{ $t('village.build.refund') }}{{ $t('village.build.time') }}{{ $t('village.build.tab_demolish') }}
{{ $t('village.build.building') }}{{ $t('village.build.tab_demolish') }}
+

{{ name }}

{{ $t('village.buildings.level_n', { level: b.level }) }}

+

+ + {{ formatDuration(b.demolish.seconds) }} +

{{ b.demolish ? formatDuration(b.demolish.seconds) : '' }} +