fix(rust): the fleet's label list prefers a capitalised spelling
All checks were successful
PR Checks / client-build (pull_request) Successful in 22s
PR Checks / frozen-manifest (pull_request) Successful in 41s
PR Checks / server-tests (pull_request) Successful in 7m45s

Found on the walk: the game spells one label "jungle swamp" on both rigs'
maps, and the fleet list printed it that way beside the minor list's
"Jungle Swamp".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
2026-09-29 18:19:31 -05:00
parent b4f71c05cc
commit 4035c523cb
2 changed files with 15 additions and 8 deletions

View File

@@ -41,17 +41,19 @@ export function serverShows(minorLabels, fleetMarkers, serverMarkers, key) {
*/
export function fleetLabels(minorLabels, servers) {
const byKey = new Map()
for (const s of servers || []) {
for (const l of s.markerLabels || []) {
const seen = byKey.get(l.key)
if (seen) seen.count += l.count || 0
else byKey.set(l.key, { key: l.key, label: l.label, count: l.count || 0 })
// A capitalised spelling wins over the game's lower-case one ("jungle swamp").
const add = (key, label, count) => {
const seen = byKey.get(key)
if (!seen) byKey.set(key, { key, label, count })
else {
seen.count += count
if (seen.label === seen.label.toLowerCase() && label !== label.toLowerCase()) seen.label = label
}
}
for (const label of minorLabels || []) {
const key = markerKey(label)
if (!byKey.has(key)) byKey.set(key, { key, label, count: 0 })
for (const s of servers || []) {
for (const l of s.markerLabels || []) add(l.key, l.label, l.count || 0)
}
for (const label of minorLabels || []) add(markerKey(label), label, 0)
return [...byKey.values()].sort((a, b) => a.label.localeCompare(b.label))
}

View File

@@ -47,6 +47,11 @@ test('the fleet list is every server’s labels and the minor list, each once',
)
})
test('the fleet list shows a capitalised spelling where the game only wrote lower case', () => {
const labels = fleetLabels(MINOR, [{ markerLabels: [{ key: 'jungle swamp', label: 'jungle swamp', count: 3 }] }])
assert.deepEqual(labels.find((l) => l.key === 'jungle swamp'), { key: 'jungle swamp', label: 'Jungle Swamp', count: 3 })
})
test('setting the fleet back to the built-in answer clears the row instead of copying it', () => {
assert.deepEqual(setFleet(MINOR, {}, 'substation', true), { substation: true })
assert.deepEqual(setFleet(MINOR, { substation: true }, 'substation', false), {})