feat(rust): chat titles rank twenty-three conditions, and admins name the categories (PLAN_REDESIGNS §5, D172-D175, D209)

- Schema: fourteen title columns on rust_player_wipe_stats (the two
  best_* distances move by GREATEST, the rest are sums), rust_weapon_kills
  (kills by weapon prefab name) and rust_title_categories (the admin's
  title per category). purge.sql drops the two tables.
- Ingest: player.tally's new fields, in one statement per frame, none
  for an older plugin's frame.
- Titles: 23 categories plus playtime, each naming where it is read
  from (a sum, a MAX, npc_kills - animal_kills in signed arithmetic, or
  a named list). The bow/melee/blade/revolver/wood/ore/plants lists are
  one file, applied when a title is read. "NPC kills" ranks human NPCs
  only (D209).
- A rule's text may be empty, meaning the category's title: the rule's
  own, then the admin's, then the default. Typed-only-markup is still
  refused. A rename forgets every server's cached answer.
- Admin API: GET /admin/rust/title-categories and
  PUT /admin/rust/title-categories/:stat (empty text resets); the server
  list returns them too. Swagger fragment and routes.manifest.json
  regenerated (63 routes, against the pinned core).
- Screen: every category in the rule form, the category's title as a
  placeholder, and a Category titles section with Save and Reset.

The weapon lists are unverified until the rig probe runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
2026-09-28 23:32:59 -05:00
parent afb16112b0
commit aea94b5d7a
18 changed files with 1150 additions and 65 deletions

View File

@@ -44,14 +44,14 @@ withCore()
const titles = require('../model/titles/titles')
const chatStyle = require('../model/permissions/chatStyle')
const row = (steamId, stats) => ({ steamId, kills: 0, npcKills: 0, playtimeSec: 0, ...stats })
const row = (steamId, value = 0) => ({ steamId, value })
// ── Titles ─────────────────────────────────────────────────────────────────
test('a title rule counts only a stat above zero, so a fresh wipe gives no titles (§33.4 reading 1)', () => {
const held = titles.evaluate(
[{ stat: 'kills', topN: 3, text: 'Killer', color: '#ff0000' }],
{ kills: [row('1', { kills: 5 }), row('2', { kills: 0 }), row('3', { kills: 0 })] },
{ kills: [row('1', 5), row('2', 0), row('3', 0)] },
)
assert.deepStrictEqual([...held.keys()], ['1'])
@@ -62,7 +62,7 @@ test('a title rule counts only a stat above zero, so a fresh wipe gives no title
test('ties follow the leaderboard order: a rule’s top N is the first N rows it was given (reading 2)', () => {
const held = titles.evaluate(
[{ stat: 'playtime', topN: 2, text: 'Regular', color: '#00ff00' }],
{ playtime: [row('9', { playtimeSec: 60 }), row('4', { playtimeSec: 60 }), row('7', { playtimeSec: 60 })] },
{ playtime: [row('9', 60), row('4', 60), row('7', 60)] },
)
assert.deepStrictEqual([...held.keys()], ['9', '4'])
})
@@ -74,9 +74,9 @@ test('the mode keeps the first rule met, every rule, or up to N — in the opera
{ stat: 'playtime', topN: 1, text: 'Regular', color: '#0000ff' },
]
const standings = {
kills: [row('1', { kills: 3 })],
npckills: [row('1', { npcKills: 2 })],
playtime: [row('1', { playtimeSec: 9 })],
kills: [row('1', 3)],
npckills: [row('1', 2)],
playtime: [row('1', 9)],
}
const texts = (mode, max) => titles.evaluate(rules, standings, { mode, max }).get('1').map((t) => t.text)