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
71 lines
3.2 KiB
JavaScript
71 lines
3.2 KiB
JavaScript
// ── Which monument labels a map draws (PLAN_REDESIGNS §4, D196) ───────────
|
||
//
|
||
// The admin card must agree with the server about what a switch means, or the
|
||
// page says a label is drawn while the map leaves it out. These are the ways it
|
||
// could disagree: case, the built-in list, the fleet under a server, and a
|
||
// switch set back to its default.
|
||
|
||
import test from 'node:test'
|
||
import assert from 'node:assert/strict'
|
||
|
||
import { builtIn, fleetLabels, fleetShows, markerDiff, markerKey, serverShows, setFleet, setServer } from '../src/lib/mapMarkers.js'
|
||
|
||
const MINOR = ['Substation', 'Jungle Swamp', 'Ranch']
|
||
|
||
test('a label becomes the same key the server stores', () => {
|
||
assert.equal(markerKey(' jungle Swamp '), 'jungle swamp')
|
||
assert.equal(markerKey(null), '')
|
||
})
|
||
|
||
test('the minor labels start hidden and every other label drawn', () => {
|
||
assert.equal(builtIn(MINOR, 'substation'), false)
|
||
assert.equal(builtIn(MINOR, 'something facepunch added'), true)
|
||
})
|
||
|
||
test('a server switch wins over the fleet, and the fleet over the built-in list', () => {
|
||
assert.equal(fleetShows(MINOR, {}, 'substation'), false)
|
||
assert.equal(fleetShows(MINOR, { substation: true }, 'substation'), true)
|
||
assert.equal(serverShows(MINOR, { substation: true }, {}, 'substation'), true)
|
||
assert.equal(serverShows(MINOR, { substation: true }, { substation: false }, 'substation'), false)
|
||
assert.equal(serverShows(MINOR, {}, { 'power plant': false }, 'power plant'), false)
|
||
})
|
||
|
||
test('the fleet list is every server’s labels and the minor list, each once', () => {
|
||
const labels = fleetLabels(MINOR, [
|
||
{ markerLabels: [{ key: 'substation', label: 'Substation', count: 31 }, { key: 'harbor', label: 'Harbor', count: 2 }] },
|
||
{ markerLabels: [{ key: 'substation', label: 'Substation', count: 12 }] },
|
||
{},
|
||
])
|
||
assert.deepEqual(
|
||
labels.map((l) => [l.key, l.count]),
|
||
[
|
||
['harbor', 2],
|
||
['jungle swamp', 0],
|
||
['ranch', 0],
|
||
['substation', 43],
|
||
],
|
||
)
|
||
})
|
||
|
||
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), {})
|
||
assert.deepEqual(setFleet(MINOR, {}, 'harbor', false), { harbor: false })
|
||
})
|
||
|
||
test('a server set to follow the fleet loses its own switch', () => {
|
||
assert.deepEqual(setServer({ substation: true }, 'substation', null), {})
|
||
assert.deepEqual(setServer({}, 'substation', false), { substation: false })
|
||
})
|
||
|
||
test('the diff sends a changed switch as its value and a removed one as null', () => {
|
||
assert.equal(markerDiff({ a: true }, { a: true }), null)
|
||
assert.deepEqual(markerDiff({ a: true, b: false }, { a: false, c: true }), { a: false, b: null, c: true })
|
||
assert.equal(markerDiff(undefined, {}), null)
|
||
})
|