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
|
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: '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 rows = computed<Row[]>(() => {
|
||||||
const out: Row[] = []
|
const out: Row[] = []
|
||||||
|
let group = 0
|
||||||
for (const o of props.options) {
|
for (const o of props.options) {
|
||||||
if (o.blocked === 'requires') continue
|
if (o.blocked === 'requires') continue
|
||||||
const instances = byType.value.get(o.type) ?? []
|
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')
|
const numbered = instances.length > 1 || (instances.length > 0 && o.blocked !== 'max_per_village')
|
||||||
instances.forEach((b, i) => {
|
instances.forEach((b, i) => {
|
||||||
out.push({
|
out.push({
|
||||||
|
group,
|
||||||
|
first: false,
|
||||||
kind: 'upgrade',
|
kind: 'upgrade',
|
||||||
key: `b${b.id}`,
|
key: `b${b.id}`,
|
||||||
type: b.type,
|
type: b.type,
|
||||||
|
|
@ -53,12 +61,16 @@ const rows = computed<Row[]>(() => {
|
||||||
// A unique type that already stands has nothing more to build.
|
// A unique type that already stands has nothing more to build.
|
||||||
if (o.blocked === 'max_per_village' && instances.length) continue
|
if (o.blocked === 'max_per_village' && instances.length) continue
|
||||||
out.push({
|
out.push({
|
||||||
|
group,
|
||||||
|
first: false,
|
||||||
kind: 'build',
|
kind: 'build',
|
||||||
key: `new-${o.type}`,
|
key: `new-${o.type}`,
|
||||||
type: 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}`),
|
name: instances.length ? t('village.build.nth', { name: t(`buildings.${o.type}`), n: instances.length + 1 }) : t(`buildings.${o.type}`),
|
||||||
option: o,
|
option: o,
|
||||||
|
another: instances.length ? instances.length + 1 : 0,
|
||||||
})
|
})
|
||||||
|
if (out[start]) out[start]!.first = true
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
})
|
})
|
||||||
|
|
@ -133,13 +145,20 @@ const demolishable = computed(() =>
|
||||||
<tr
|
<tr
|
||||||
v-for="row in rows"
|
v-for="row in rows"
|
||||||
:key="row.key"
|
:key="row.key"
|
||||||
class="border-b border-parchment-300 last:border-b-0"
|
class="border-parchment-300"
|
||||||
:class="row.type === hint ? 'quest-hint' : 'even:bg-parchment-100'"
|
: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"
|
: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">
|
<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">
|
<div class="min-w-0 leading-tight">
|
||||||
<button
|
<button
|
||||||
v-if="row.kind === 'upgrade'"
|
v-if="row.kind === 'upgrade'"
|
||||||
|
|
@ -152,7 +171,13 @@ const demolishable = computed(() =>
|
||||||
</button>
|
</button>
|
||||||
<p v-else class="truncate font-semibold">{{ row.name }}</p>
|
<p v-else class="truncate font-semibold">{{ row.name }}</p>
|
||||||
<p class="text-xs text-ink-500">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -187,8 +212,8 @@ const demolishable = computed(() =>
|
||||||
:disabled="busy"
|
:disabled="busy"
|
||||||
@click="emit('build', row.type)"
|
@click="emit('build', row.type)"
|
||||||
>
|
>
|
||||||
<IconUi name="hammer" class="size-3.5" />
|
<IconUi :name="row.another ? 'plus' : 'hammer'" class="size-3.5" />
|
||||||
{{ $t('village.build.submit') }}
|
{{ $t(row.another ? 'village.build.submit_another' : 'village.build.submit') }}
|
||||||
</button>
|
</button>
|
||||||
<span v-else class="text-xs font-semibold text-blood-700">{{ reason(row.option) }}</span>
|
<span v-else class="text-xs font-semibold text-blood-700">{{ reason(row.option) }}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,8 @@ export default {
|
||||||
tab_demolish: 'Demolition',
|
tab_demolish: 'Demolition',
|
||||||
nth: '{name} {n}',
|
nth: '{name} {n}',
|
||||||
not_built: 'Not built yet',
|
not_built: 'Not built yet',
|
||||||
|
another_hint: 'New copy, not built yet',
|
||||||
|
submit_another: 'Build another',
|
||||||
level_button: 'Level {level}',
|
level_button: 'Level {level}',
|
||||||
refund: 'Refund',
|
refund: 'Refund',
|
||||||
remove: 'Remove',
|
remove: 'Remove',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue