Files
Module-Rust/client/test/mapEvents.test.js
wtclaude 549b3a5ffd
All checks were successful
PR Checks / client-build (pull_request) Successful in 25s
PR Checks / server-tests (pull_request) Successful in 31s
PR Checks / frozen-manifest (pull_request) Successful in 44s
feat(rust): Dynamic PVP's zones on the feed and the map (PLAN_REDESIGNS §14.3.3)
Stage 4 of the §14.3 integration plan, on protocol 14 (docs
rust-link/PROTOCOL.md §20.7).

- pvp.zone.created is a public kind, pvp.zone.deleted a staff kind. Each row
  is read per viewer by the new dynamicPvp.js: grid for everyone, the event's
  name only for Dynamic PVP's own vanilla events, position and zone id for
  staff only.
- The feed's world filter carries the opening: "A PvP zone opened around the
  downed patrol helicopter · G7 · for 10 min". It names nobody.
- The map gains a fifth layer, `pvp` (PvP zones), public by default with its
  own audience in Admin → Rust visibility, drawn as a red ring with its
  event's name.
- Server settings' plugin line names Dynamic PVP; the swagger schemas and
  route descriptions carry the layer and the integration (fragment
  regenerated); ci/bundle.json ships dynamicPvp.js; README lists it.

Tests: server 611/611 (dynamicPvp.test.js new, catalogue and map extended)
and every check; client 89/89 (feed and map tooltip), build and externals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
2026-10-15 06:12:07 -05:00

62 lines
2.8 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 { createRequire } from 'node:module'
import { eventTip, isBoss, pvpTip, PVP_NAMES, 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'])
})
// Dynamic PVP's rings (PLAN_REDESIGNS §14.3.3): its own events by a plain name,
// a monument's or an operator's as written, and nothing at all as just a zone.
test('a Dynamic PVP ring says what it is around', () => {
assert.equal(pvpTip({ event: 'Helicopter' }), 'PvP zone · Patrol helicopter')
assert.equal(pvpTip({ event: 'Airfield' }), 'PvP zone · Airfield')
assert.equal(pvpTip({}), 'PvP zone')
const { GENERAL_EVENTS } = createRequire(import.meta.url)('../../server/dynamicPvp.js')
assert.deepEqual(Object.keys(PVP_NAMES).sort(), [...GENERAL_EVENTS].sort())
})