Files
Module-Rust/client/test/mapEvents.test.js
wtclaude 5162496d74
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
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
2026-10-06 08:23:13 -05:00

50 lines
2.2 KiB
JavaScript

// ── What an event marker says (runicnpc stage 8, D302, D303) ──────────────
//
// The decisions: a name and an event title, never health; a boss marked and
// drawn bigger; an unannounced event named by nothing but "an event".
import test from 'node:test'
import assert from 'node:assert/strict'
import { eventTip, isBoss, titlesFrom, unknownRuns } from '../src/lib/mapEvents.js'
const CALENDAR = {
entries: [
{ kind: 'run', runId: 41, title: 'Harbour Raid' },
{ kind: 'projected', title: 'Next week' },
{ kind: 'run', runId: 42, title: '' },
],
}
test("the calendar's runs become titles by run id; a projection has none", () => {
assert.deepEqual(titlesFrom(CALENDAR), { 41: 'Harbour Raid' })
assert.deepEqual(titlesFrom(null), {})
})
test('an NPC says its name and its event; a boss and an add say which they are', () => {
const titles = titlesFrom(CALENDAR)
assert.equal(eventTip({ kind: 'npc', runId: '41', name: 'Bandit' }, titles), 'Bandit · Harbour Raid')
assert.equal(eventTip({ kind: 'npc', runId: '41', name: 'The Juggernaut', boss: true }, titles), 'The Juggernaut (boss) · Harbour Raid')
assert.equal(eventTip({ kind: 'npc', runId: '41', name: 'Bandit', add: true }, titles), "Bandit (a boss's add) · Harbour Raid")
})
test('an unannounced event, a Rust scientist and a crate', () => {
assert.equal(eventTip({ kind: 'npc', runId: '7', name: 'Bandit' }, {}), 'Bandit · an event')
assert.equal(eventTip({ kind: 'npc', runId: '41' }, { 41: 'Harbour Raid' }), 'Event NPC · Harbour Raid')
assert.equal(eventTip({ kind: 'crate', runId: '41' }, { 41: 'Harbour Raid' }), 'Event crate · Harbour Raid')
})
test('health never reaches a tooltip, even if a row carried it', () => {
assert.equal(eventTip({ kind: 'npc', runId: '41', name: 'J', boss: true, health: 0.5 }, {}).includes('50'), false)
})
test('a boss is an event boss or a world one', () => {
assert.equal(isBoss({ kind: 'npc', boss: true }), true)
assert.equal(isBoss({ kind: 'boss' }), true)
assert.equal(isBoss({ kind: 'npc' }), false)
})
test('the run ids still to look up', () => {
assert.deepEqual(unknownRuns([{ runId: '41' }, { runId: '7' }, { runId: '7' }, {}], { 41: 'x' }), ['7'])
})