feat(rust): the live map draws monuments by label, minor labels hidden (PLAN_REDESIGNS §4, D196, D213) #28

Merged
whitlocktech merged 3 commits from feat/map-marker-labels into edge 2026-09-30 00:17:26 +00:00
2 changed files with 15 additions and 8 deletions
Showing only changes of commit 4035c523cb - Show all commits

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), {})