feat(rust): event NPCs named on the map, and a Place NPCs step's progress line (runicnpc stage 8)
- rust.npc.place's progress() (MODULE_API 1.12.0, D304). It reports the
step's NPCs still standing, by its key, of how many it placed, with
the profile's label: "Bandit: 2 of 3 left". A boss step is its
health, "Walk Juggernaut: 59%", and a boss's adds are not counted.
The data comes from the map's live answer, so it costs the game no
extra ask. A reader who may not see the map's events layer gets no
line.
- The map (D302, D303):
- an NPC's tooltip is its name and its event's title, read from
core's public calendar, which lists only announced events;
- a boss is bigger and in its own colour, and an add says so;
- a boss outside any event is in the world layer;
- a boss's health is removed from what a viewer is sent.
- The world layer's visibility hint mentions those bosses.
coreApi stays ^1.11.0: an older core ignores the optional member, and
the action works without a progress line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -301,6 +301,13 @@ async function mateIdsFor(serverId, acc) {
|
||||
return { own, mates: new Set(clan.filter((id) => !own.has(id))) }
|
||||
}
|
||||
|
||||
/** An events row without the health a boss's carries. */
|
||||
function withoutHealth(row) {
|
||||
if (!row || typeof row !== 'object' || !('health' in row)) return row
|
||||
const { health, ...rest } = row
|
||||
return rest
|
||||
}
|
||||
|
||||
/**
|
||||
* One live answer, cut down to what one viewer may see. **Pure**, and the
|
||||
* security boundary in one function: a layer the viewer may not see is not in
|
||||
@@ -315,7 +322,9 @@ function project(live, acc, ids = { own: new Set(), mates: new Set() }) {
|
||||
const out = { mapKey: live.mapKey || null, t: live.t || null }
|
||||
|
||||
if (acc.layers.world.visible) out.world = Array.isArray(live.world) ? live.world : []
|
||||
if (acc.layers.events.visible) out.events = Array.isArray(live.events) ? live.events : []
|
||||
// A boss's health rides on the wire for the event page's progress line, and the
|
||||
// map does not show it (runicnpc D303), so it is not in what a viewer is sent.
|
||||
if (acc.layers.events.visible) out.events = Array.isArray(live.events) ? live.events.map(withoutHealth) : []
|
||||
if (acc.layers.players.visible) {
|
||||
out.players = Array.isArray(live.players) ? live.players : []
|
||||
if (live.playersTruncated) out.playersTruncated = true
|
||||
|
||||
Reference in New Issue
Block a user