feat: headquarters list groups each building type and indents building one more copy under its instances (Build another)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
241c2a8f7f
commit
de06778071
|
|
@ -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<Row[]>(() => {
|
||||
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<Row[]>(() => {
|
|||
// 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(() =>
|
|||
<tr
|
||||
v-for="row in rows"
|
||||
:key="row.key"
|
||||
class="border-b border-parchment-300 last:border-b-0"
|
||||
:class="row.type === hint ? 'quest-hint' : 'even:bg-parchment-100'"
|
||||
class="border-parchment-300"
|
||||
:class="[row.type === hint ? 'quest-hint' : row.group % 2 ? 'bg-parchment-100' : '', row.first ? 'border-t-2 border-t-parchment-400' : 'border-t']"
|
||||
:data-hint="row.type === hint ? '' : undefined"
|
||||
>
|
||||
<td class="px-3 py-1">
|
||||
<td class="py-1 pr-3" :class="row.kind === 'build' && row.another ? 'pl-12' : 'pl-3'">
|
||||
<div class="flex items-center gap-2">
|
||||
<VillagePortraitTile :type="row.type" :level="row.kind === 'upgrade' ? row.building.level : 1" class="size-8" />
|
||||
<span
|
||||
v-if="row.kind === 'build' && row.another"
|
||||
class="grid size-6 shrink-0 place-items-center border border-dashed border-wood-700 text-wood-800"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<IconUi name="plus" class="size-3.5" />
|
||||
</span>
|
||||
<VillagePortraitTile v-else :type="row.type" :level="row.kind === 'upgrade' ? row.building.level : 1" class="size-8" />
|
||||
<div class="min-w-0 leading-tight">
|
||||
<button
|
||||
v-if="row.kind === 'upgrade'"
|
||||
|
|
@ -152,7 +171,13 @@ const demolishable = computed(() =>
|
|||
</button>
|
||||
<p v-else class="truncate font-semibold">{{ row.name }}</p>
|
||||
<p class="text-xs text-ink-500">
|
||||
{{ 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')
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -187,8 +212,8 @@ const demolishable = computed(() =>
|
|||
:disabled="busy"
|
||||
@click="emit('build', row.type)"
|
||||
>
|
||||
<IconUi name="hammer" class="size-3.5" />
|
||||
{{ $t('village.build.submit') }}
|
||||
<IconUi :name="row.another ? 'plus' : 'hammer'" class="size-3.5" />
|
||||
{{ $t(row.another ? 'village.build.submit_another' : 'village.build.submit') }}
|
||||
</button>
|
||||
<span v-else class="text-xs font-semibold text-blood-700">{{ reason(row.option) }}</span>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue