feat(rust): event NPCs named on the map, and a Place NPCs step's progress line (runicnpc stage 8)
All checks were successful
PR Checks / client-build (pull_request) Successful in 20s
PR Checks / server-tests (pull_request) Successful in 25s
PR Checks / frozen-manifest (pull_request) Successful in -1m18s

- 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:
2026-10-06 08:23:13 -05:00
parent 3c3d154b36
commit 5162496d74
14 changed files with 484 additions and 11 deletions

View File

@@ -0,0 +1,44 @@
// ── What an event marker says (runicnpc stage 8, D302, D303) ──────────────
//
// An NPC's marker says its name and its event; a boss is drawn bigger, and no
// health is shown (D303 — the server does not even send it). A boss placed
// outside any event is in the world layer as `kind: 'boss'` (D302).
//
// The event's title comes from core's public calendar, which publishes each
// run's id for this: a map row holds a run id and nothing else. The calendar
// lists announced events only, so an unannounced event is "an event" here and
// nothing more.
//
// Pure, and free of React, so it is tested in Node.
/** `{ [runId]: title }` from core's public calendar answer. */
export function titlesFrom(calendar) {
const out = {}
for (const e of (calendar && calendar.entries) || []) {
if (e && e.kind === 'run' && e.runId != null && e.title) out[String(e.runId)] = e.title
}
return out
}
/** The run ids an answer's events layer names that `titles` does not know yet. */
export function unknownRuns(events, titles) {
const out = new Set()
for (const e of events || []) {
if (e && e.runId != null && !Object.prototype.hasOwnProperty.call(titles || {}, String(e.runId))) out.add(String(e.runId))
}
return [...out]
}
/** The tooltip for one events-layer row that is not a zone. */
export function eventTip(row, titles) {
const event = (titles && row && row.runId != null && titles[String(row.runId)]) || 'an event'
if (!row || row.kind !== 'npc') return `Event crate · ${event}`
const who = row.name || 'Event NPC'
const role = row.boss ? ' (boss)' : row.add ? " (a boss's add)" : ''
return `${who}${role} · ${event}`
}
/** Whether a row is drawn as a boss: bigger (D303). */
export function isBoss(row) {
return Boolean(row && (row.boss || row.kind === 'boss'))
}