feat(rust): Guarded Crate — feed, map, Warden, Place a guarded crate (PLAN_REDESIGNS §14.3.5)
Stage 6 of the §14.3 integration plan, on protocol 14. Spec: docs rust-link/PROTOCOL.md §20.9. - gc.started and gc.ended public, gc.failed staff's; guardedCrate.js reads each row per viewer (the clearer's name for the presence audience, Steam id, position and key for staff, `won` for everyone). - Triggers rust.gc.started and rust.gc.ended (a crate a player cleared only). - The step rust.gc.place: an event from rust.options.gc_events and a world call's location; refused at verify for Guarded Crate absent, NpcSpawn missing (D364), console unavailable, or an unknown event. Kept (D373); the run log's success line says so (D380). Budget rust.gc.crates. - Warden (D375): guarded_won, title category guardedwon, Crates cleared column. - Map marker, server settings line, swagger, engagement manifest, bundle, README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -46,6 +46,10 @@ const COLUMNS = [
|
||||
// rows already count a treasure, so the column is there exactly then.
|
||||
const TREASURES = { key: 'treasuresWon', label: 'Treasures', sort: 'treasuresWon', value: (r) => count(r.treasuresWon) }
|
||||
|
||||
// Warden (PLAN_REDESIGNS §14.3.5, D375): guarded crates cleared, shown on the
|
||||
// same rule from the server's `guardedCrate`.
|
||||
const GUARDED = { key: 'guardedWon', label: 'Crates cleared', sort: 'guardedWon', value: (r) => count(r.guardedWon) }
|
||||
|
||||
const BALANCE = { key: 'balance', label: 'Coins', sort: 'balance', value: (r) => coins(r.balance) }
|
||||
|
||||
export default function Leaderboard({ serverId, wipeId, sort, onSort }) {
|
||||
@@ -104,6 +108,7 @@ function Overall({ serverId, wipeId, sort, onSort }) {
|
||||
const columns = [
|
||||
...COLUMNS,
|
||||
...(data && data.dangerousTreasures ? [TREASURES] : []),
|
||||
...(data && data.guardedCrate ? [GUARDED] : []),
|
||||
...(data && data.economics ? [BALANCE] : []),
|
||||
]
|
||||
// Present on every row or on none — the server decides per request.
|
||||
|
||||
@@ -47,6 +47,7 @@ const COLOURS = {
|
||||
supply: '#66bb6a',
|
||||
crate: '#ffee58',
|
||||
treasure: '#ffab00',
|
||||
guarded: '#ff7043',
|
||||
event: '#ce93d8',
|
||||
boss: '#d500f9',
|
||||
online: '#ffffff',
|
||||
@@ -67,6 +68,8 @@ const WORLD_NAMES = {
|
||||
crate: 'Locked crate',
|
||||
// Dangerous Treasures (§14.3.4): its running chests.
|
||||
treasure: 'Dangerous Treasures chest',
|
||||
// Guarded Crate (§14.3.5): a crate whose guards still stand.
|
||||
guarded: 'Guarded crate',
|
||||
boss: 'Boss',
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,10 @@ export const FEED_KINDS = Object.freeze([
|
||||
// ending (`dt.ended`) is staff's, and the map shows the chest go.
|
||||
'dt.started',
|
||||
'dt.won',
|
||||
// Guarded Crate (§14.3.5): a crate landing, and one cleared, read per viewer
|
||||
// like a treasure. A timeout (`gc.failed`) is staff's; the map shows it go.
|
||||
'gc.started',
|
||||
'gc.ended',
|
||||
])
|
||||
|
||||
/** The filters the feed offers, and the kinds each one asks the API for. */
|
||||
@@ -69,7 +73,7 @@ export const FILTERS = Object.freeze([
|
||||
},
|
||||
{ id: 'server', label: 'Server', kinds: ['server.wipe', 'server.initialized', 'server.shutdown'] },
|
||||
{ id: 'bosses', label: 'Bosses', kinds: ['npc.boss.spawned', 'npc.boss.died'] },
|
||||
{ id: 'world', label: 'World events', kinds: ['world.event', 'pvp.zone.created', 'dt.started', 'dt.won'] },
|
||||
{ id: 'world', label: 'World events', kinds: ['world.event', 'pvp.zone.created', 'dt.started', 'dt.won', 'gc.started', 'gc.ended'] },
|
||||
])
|
||||
|
||||
export function kindsFor(filterId) {
|
||||
@@ -168,6 +172,11 @@ export function describe(row) {
|
||||
case 'dt.ended':
|
||||
return treasureLine(row.kind, frame)
|
||||
|
||||
case 'gc.started':
|
||||
case 'gc.ended':
|
||||
case 'gc.failed':
|
||||
return guardedLine(row.kind, frame)
|
||||
|
||||
default:
|
||||
return { tone: 'other', actor: name, verb: String((row && row.kind) || 'unknown'), subject: null, detail: '' }
|
||||
}
|
||||
@@ -377,4 +386,25 @@ function treasureLine(kind, frame) {
|
||||
: { tone: 'kill', actor: null, verb: 'The treasure was won', subject: null, detail }
|
||||
}
|
||||
|
||||
/**
|
||||
* Guarded Crate (protocol 14, PLAN_REDESIGNS §14.3.5). The server has read the
|
||||
* frame for this viewer: `grid`, `won` (whether a player killed the last
|
||||
* guard), and the clearer's `name` only for the presence audience (D376).
|
||||
*/
|
||||
function guardedLine(kind, frame) {
|
||||
const detail = frame.grid || ''
|
||||
if (kind === 'gc.started') {
|
||||
return { tone: 'server', actor: null, verb: 'A guarded crate landed', subject: null, detail }
|
||||
}
|
||||
if (kind === 'gc.failed') {
|
||||
return { tone: 'server', actor: null, verb: 'A guarded crate timed out with its guards standing', subject: null, detail }
|
||||
}
|
||||
if (frame.won === false) {
|
||||
return { tone: 'server', actor: null, verb: 'A guarded crate ended with nobody clearing it', subject: null, detail }
|
||||
}
|
||||
return frame.name
|
||||
? { tone: 'kill', actor: frame.name, verb: 'cleared the guarded crate', subject: null, detail }
|
||||
: { tone: 'kill', actor: null, verb: 'The guarded crate was cleared', subject: null, detail }
|
||||
}
|
||||
|
||||
export default { describe, FEED_KINDS, FILTERS, kindsFor }
|
||||
|
||||
@@ -264,7 +264,29 @@ export function integrationsLine(r) {
|
||||
const withBackpacks = r.integrations.backpacks ? `${withEconomics} ${backpacksLine(r.integrations.backpacks)}` : withEconomics
|
||||
const withTruePve = r.integrations.truePve ? `${withBackpacks} ${truePveLine(r.integrations.truePve)}` : withBackpacks
|
||||
const withDynamicPvp = r.integrations.dynamicPvp ? `${withTruePve} ${dynamicPvpLine(r.integrations.dynamicPvp)}` : withTruePve
|
||||
return r.integrations.dangerousTreasures ? `${withDynamicPvp} ${dangerousTreasuresLine(r.integrations.dangerousTreasures, r.console)}` : withDynamicPvp
|
||||
const withDt = r.integrations.dangerousTreasures ? `${withDynamicPvp} ${dangerousTreasuresLine(r.integrations.dangerousTreasures, r.console)}` : withDynamicPvp
|
||||
return r.integrations.guardedCrate ? `${withDt} ${guardedCrateLine(r.integrations.guardedCrate, r.console)}` : withDt
|
||||
}
|
||||
|
||||
/**
|
||||
* Guarded Crate (PLAN_REDESIGNS §14.3.5), from protocol 14, with NpcSpawn beside it
|
||||
* (D364): its crates on the feed and the map, and whether a step can place one,
|
||||
* which needs NpcSpawn for the guards and the framework to run its console command.
|
||||
*/
|
||||
export function guardedCrateLine(gc, probe) {
|
||||
const npc = gc.npcSpawn && gc.npcSpawn.loaded ? `NpcSpawn ${gc.npcSpawn.version || ''}`.trim() : null
|
||||
if (!gc.loaded) {
|
||||
return `Guarded Crate is not loaded — a step cannot place a guarded crate.${npc ? ` ${npc} is loaded.` : ''}`
|
||||
}
|
||||
const name = `Guarded Crate ${gc.version || ''}`.trim()
|
||||
const events = Array.isArray(gc.events) && gc.events.length ? ` Its events: ${gc.events.join(', ')}.` : ''
|
||||
if (!npc) {
|
||||
return `${name} is loaded but NpcSpawn is missing: its events cannot start, and a step cannot place one.`
|
||||
}
|
||||
if (probe && probe.plugins === false) {
|
||||
return `${name} is loaded with ${npc} — its crates show on the feed and the map, but this framework cannot run its console command, so a step cannot place one (Rust-Plugins#34).${events}`
|
||||
}
|
||||
return `${name} is loaded with ${npc} — its crates show on the feed and the map, and a step may place one.${events}`
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -203,9 +203,10 @@ test('every type the server knows has its own words, and an unknown one says its
|
||||
assert.equal(describe(world({ event: 'meteor.landed' })).verb, 'meteor.landed')
|
||||
})
|
||||
|
||||
test('the world filter asks for world events, Dynamic PVP zones opening and Dangerous Treasures, which the server serves publicly', () => {
|
||||
assert.deepEqual(kindsFor('world'), ['world.event', 'pvp.zone.created', 'dt.started', 'dt.won'])
|
||||
test('the world filter asks for world events, Dynamic PVP zones opening, Dangerous Treasures and Guarded Crate, which the server serves publicly', () => {
|
||||
assert.deepEqual(kindsFor('world'), ['world.event', 'pvp.zone.created', 'dt.started', 'dt.won', 'gc.started', 'gc.ended'])
|
||||
assert.ok(!FEED_KINDS.includes('dt.ended'), 'a treasure event ending is a staff line')
|
||||
assert.ok(!FEED_KINDS.includes('gc.failed'), 'a guarded crate timing out is a staff line')
|
||||
assert.ok(FEED_KINDS.includes('pvp.zone.created'))
|
||||
assert.ok(!FEED_KINDS.includes('pvp.zone.deleted'), 'a zone closing is a staff line')
|
||||
})
|
||||
@@ -271,3 +272,30 @@ test('a win names its winner only when the server sent the name, and says how ma
|
||||
test('a treasure event ending, for a staff reader, is its own line', () => {
|
||||
assert.equal(describe(treasure('dt.ended', { grid: 'K12' })).verb, 'A Dangerous Treasures event has ended')
|
||||
})
|
||||
|
||||
// ── Guarded Crate (protocol 14, PLAN_REDESIGNS §14.3.5) ───────────────────
|
||||
|
||||
const guarded = (kind, frame) => row(kind, { kind, ...frame })
|
||||
|
||||
test('a guarded crate landing says where, and names nobody', () => {
|
||||
const line = describe(guarded('gc.started', { grid: 'M4' }))
|
||||
assert.equal(line.verb, 'A guarded crate landed')
|
||||
assert.equal(line.detail, 'M4')
|
||||
assert.equal(line.actor, null)
|
||||
})
|
||||
|
||||
test('a clearing names its clearer only when the server sent the name', () => {
|
||||
const named = describe(guarded('gc.ended', { grid: 'M4', won: true, name: 'Alice' }))
|
||||
assert.equal(named.actor, 'Alice')
|
||||
assert.equal(named.verb, 'cleared the guarded crate')
|
||||
assert.equal(named.detail, 'M4')
|
||||
|
||||
const unnamed = describe(guarded('gc.ended', { grid: 'M4', won: true }))
|
||||
assert.equal(unnamed.actor, null)
|
||||
assert.equal(unnamed.verb, 'The guarded crate was cleared')
|
||||
})
|
||||
|
||||
test('an ending with nobody clearing it, and a timeout for a staff reader, are their own lines', () => {
|
||||
assert.equal(describe(guarded('gc.ended', { grid: 'M4', won: false })).verb, 'A guarded crate ended with nobody clearing it')
|
||||
assert.equal(describe(guarded('gc.failed', { grid: 'M4' })).verb, 'A guarded crate timed out with its guards standing')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user