diff --git a/app/components/village/BuildForm.vue b/app/components/village/BuildForm.vue index aeb920e..188040d 100644 --- a/app/components/village/BuildForm.vue +++ b/app/components/village/BuildForm.vue @@ -30,18 +30,26 @@ const byType = computed(() => { return map }) -type Row = +// 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 } + | { kind: 'build'; key: string; type: BuildingType; name: string; option: BuildOption; another: number } +) const rows = computed(() => { const out: Row[] = [] + let group = 0 for (const o of props.options) { if (o.blocked === 'requires') continue const instances = byType.value.get(o.type) ?? [] + 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, @@ -53,12 +61,16 @@ const rows = computed(() => { // 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 (out[start]) out[start]!.first = true } return out }) @@ -133,13 +145,20 @@ const demolishable = computed(() => - +
- + +

{{ row.name }}

- {{ row.kind === 'upgrade' ? $t('village.buildings.level_n', { level: row.building.level }) : $t('village.build.not_built') }} + {{ + row.kind === 'upgrade' + ? $t('village.buildings.level_n', { level: row.building.level }) + : row.another + ? $t('village.build.another_hint') + : $t('village.build.not_built') + }}

@@ -187,8 +212,8 @@ const demolishable = computed(() => :disabled="busy" @click="emit('build', row.type)" > - - {{ $t('village.build.submit') }} + + {{ $t(row.another ? 'village.build.submit_another' : 'village.build.submit') }} {{ reason(row.option) }} diff --git a/i18n/pages/village.ts b/i18n/pages/village.ts index 6966015..3eece76 100644 --- a/i18n/pages/village.ts +++ b/i18n/pages/village.ts @@ -292,6 +292,8 @@ export default { tab_demolish: 'Demolition', nth: '{name} {n}', not_built: 'Not built yet', + another_hint: 'New copy, not built yet', + submit_another: 'Build another', level_button: 'Level {level}', refund: 'Refund', remove: 'Remove',