feat(rust): RaidableBases — feed, raids map layer, Warlord, Spawn a raid base, profiles (PLAN_REDESIGNS §11.4)
All checks were successful
PR Checks / server-tests (pull_request) Successful in 37s
PR Checks / client-build (pull_request) Successful in 24s
PR Checks / frozen-manifest (pull_request) Successful in 49s

PLAN_REDESIGNS §11.4 (D202-D208, D386-D391), protocol 14. Spec: docs
rust-link/PROTOCOL.md §20.12.

- raid.started, raid.completed, raid.purchased and raid.locked public,
  raid.ended staff's; raidableBases.js reads each row per viewer (raiders'
  and a buyer's names only for the presence audience, D376/D390; Steam ids,
  position and a run's key only for staff). Feed lines in the World filter.
- The step rust.raidbase.spawn, "Spawn a raid base" (ledgered, budget
  rust.raids): difficulty, profile and base from option sources listing each
  server's own names (D386), a spot as a world call's location with a height
  adjustment or an exact height, and PvP/NPCs/lock as on/off/blank. A base
  the raids helper made is a world resource, so eventWorld's revert and
  reconcile serve it and world.expired marks it expired; one it did not make
  records nothing and the run log says it despawns on its own timer. Refused
  at verify for a server that said it cannot; a dry run with a spot returns
  the spot check as detail.warnings (MODULE_API 1.16.0, D391). rb-not-ready
  retries in ten minutes.
- Warlord: raids_completed, title category raidscompleted, the leaderboard's
  Raid bases column (sort=raidsCompleted).
- The map's raids layer (D114), public by default with its own audience; the
  run's key is dropped before any viewer gets it.
- Server settings' line for RaidableBases; its profiles in Mod configuration
  under a virtual path (D205).
- Swagger fragment, bundle and README.

Tests: server 684/684 (raidableBases.test.js new, every name in it invented);
client 99/99, build and externals.

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-16 15:18:52 -05:00
parent 49d9e42a23
commit 481837e937
34 changed files with 1996 additions and 38 deletions

View File

@@ -43,8 +43,15 @@ const LOCKED_REASON = {
*/
const PATH_SHAPE = /^(?!.*\.\.)(?!\/)[A-Za-z0-9 _.\-()[\]]+(?:\/[A-Za-z0-9 _.\-()[\]]+)*\.json$/
/**
* RaidableBases' profiles (PLAN_REDESIGNS §11.4.3, D205): the one named exception
* to the editor never walking a data directory. The bridge lists them under this
* virtual prefix, one file deep, and resolves it to that folder alone.
*/
const PROFILE_PATH = /^@data\/RaidableBases\/Profiles\/(?!.*\.\.)[A-Za-z0-9 _.\-()[\]]+\.json$/
function isPlausiblePath(path) {
return typeof path === 'string' && path.length > 0 && path.length <= 255 && PATH_SHAPE.test(path)
return typeof path === 'string' && path.length > 0 && path.length <= 255 && (PATH_SHAPE.test(path) || PROFILE_PATH.test(path))
}
/**
@@ -90,6 +97,8 @@ function shapeCatalogue(catalogue) {
modified: file.modified ? Number(file.modified) : null,
editable: file.editable !== false,
...(file.reason ? { reason: String(file.reason) } : {}),
// A RaidableBases profile (D205): reloaded through the raids helper, never a plugin reload.
...(file.profile === true ? { profile: true } : {}),
})
}

View File

@@ -155,6 +155,8 @@ const TITLE_SUMS = {
treasuresWon: 'treasures_won',
// Protocol 14 (D375): Warden.
guardedWon: 'guarded_won',
// Protocol 14 (§11.4, D202): Warlord.
raidsCompleted: 'raids_completed',
}
/** The two *best* fields and their columns: the longest single kill, never a sum. */
@@ -358,6 +360,8 @@ async function leaderboard({ serverId, wipeId = null, sort = 'kills', limit = 25
treasuresWon: 'treasures_won',
// Protocol 14 (D375): guarded crates cleared, Warden's column.
guardedWon: 'guarded_won',
// Protocol 14 (§11.4, D202): RaidableBases bases completed, Warlord's column.
raidsCompleted: 'raids_completed',
}[sort] || 'kills'
const params = [serverId]
@@ -386,6 +390,7 @@ async function leaderboard({ serverId, wipeId = null, sort = 'kills', limit = 25
SUM(s.drops_looted) AS dropsLooted,
SUM(s.treasures_won) AS treasuresWon,
SUM(s.guarded_won) AS guardedWon,
SUM(s.raids_completed) AS raidsCompleted,
MAX(s.balance) AS balance,
MAX(s.last_seen) AS lastSeen
FROM ${STATS} s

View File

@@ -17,6 +17,7 @@ const worldEvents = require('../../worldEvents')
const dynamicPvp = require('../../dynamicPvp')
const dangerousTreasures = require('../../dangerousTreasures')
const guardedCrate = require('../../guardedCrate')
const raidableBases = require('../../raidableBases')
const db = require('./events.db')
const mapDb = require('../map/map.db')
const serversDb = require('../servers/servers.db')
@@ -72,7 +73,7 @@ async function recent({ serverId, admin = false, staff = false, presence = false
})
const shaped = rows.map(shape)
if (!shaped.some((r) => r.kind === 'world.event' || dynamicPvp.KINDS.includes(r.kind) || dangerousTreasures.isKind(r.kind) || guardedCrate.isKind(r.kind))) return shaped
if (!shaped.some((r) => r.kind === 'world.event' || dynamicPvp.KINDS.includes(r.kind) || dangerousTreasures.isKind(r.kind) || guardedCrate.isKind(r.kind) || raidableBases.isKind(r.kind))) return shaped
// Protocol 14 (§14.3.1): each world event is read for THIS viewer — its type
// allowed, its names to the presence audience, its Steam ids to staff, its
@@ -88,6 +89,7 @@ async function recent({ serverId, admin = false, staff = false, presence = false
if (dynamicPvp.KINDS.includes(row.kind)) return pvpRow(row, view)
if (dangerousTreasures.isKind(row.kind)) return dtRow(row, view)
if (guardedCrate.isKind(row.kind)) return gcRow(row, view)
if (raidableBases.isKind(row.kind)) return raidRow(row, view)
return row
})
.filter(Boolean)
@@ -124,6 +126,11 @@ function gcRow(row, view) {
return { ...row, steamId: view.staff ? row.steamId : null, frame: guardedCrate.shapeFor(row.frame, view) }
}
/** One RaidableBases row for a viewer (§11.4). The row's own Steam id, a buyer's, is staff's. */
function raidRow(row, view) {
return { ...row, steamId: view.staff ? row.steamId : null, frame: raidableBases.shapeFor(row.frame, view) }
}
/** One world-event row for a viewer, or null when they may not see it. The row's own Steam id is staff's too. */
function worldRow(row, view) {
const frame = worldEvents.shapeFor(row.frame, view)
@@ -193,6 +200,8 @@ async function leaderboard({ serverId, wipeId = null, sort = 'kills', limit, pre
treasuresWon: Number(r.treasuresWon) || 0,
// Protocol 14 (D375): Warden's count.
guardedWon: Number(r.guardedWon) || 0,
// Protocol 14 (§11.4, D202): Warlord's count.
raidsCompleted: Number(r.raidsCompleted) || 0,
// Withheld below the presence audience. A tally refreshes it every minute a
// player is on, so a `lastSeen` of forty seconds ago is the Online tab by
// another name. The ORDER still uses it as a tie-break — that says who was

View File

@@ -15,8 +15,9 @@
// players who is on the server and where, and the sleepers
// bases tool cupboards and player vending machines, as positions only
// pvp Dynamic PVP's own PvP zones, where they are now (protocol 14)
// raids RaidableBases' live bases, and which a run made (protocol 14)
//
// Defaults: world, events and pvp public; players and bases staff. The audiences are the
// Defaults: world, events, pvp and raids public; players and bases staff. The audiences are the
// presence rungs (`staff` · `signed_in` · `public`) and follow its asymmetric
// fallbacks: an unknown stored word narrows to staff, an unknown viewer is
// public (`model/visibility`).
@@ -45,9 +46,11 @@ const log = core.logger('map')
// `pvp` (protocol 14, PLAN_REDESIGNS §14.3.3) is Dynamic PVP's own zones, public by
// default: the game draws them for everyone near one, and they name nobody.
const LAYERS = Object.freeze(['world', 'events', 'players', 'bases', 'pvp'])
// `raids` (protocol 14, PLAN_REDESIGNS §11.4, D114) is RaidableBases' live bases, public
// by default: the plugin marks them on the game's own map for everyone, and they name nobody.
const LAYERS = Object.freeze(['world', 'events', 'players', 'bases', 'pvp', 'raids'])
const DEFAULTS = Object.freeze({ world: 'public', events: 'public', players: 'staff', bases: 'staff', pvp: 'public' })
const DEFAULTS = Object.freeze({ world: 'public', events: 'public', players: 'staff', bases: 'staff', pvp: 'public', raids: 'public' })
/** D118: on, because it shows a member nothing the game does not already show them. */
const DEFAULT_MATES = true
@@ -304,6 +307,13 @@ async function mateIdsFor(serverId, acc) {
return { own, mates: new Set(clan.filter((id) => !own.has(id))) }
}
/** A raids row without the run's idempotency key, which only the bridge's own bookkeeping needs. */
function withoutKey(row) {
if (!row || typeof row !== 'object' || !('key' in row)) return row
const { key, ...rest } = row
return rest
}
/** An events row without the health a boss's carries. */
function withoutHealth(row) {
if (!row || typeof row !== 'object' || !('health' in row)) return row
@@ -334,6 +344,8 @@ function project(live, acc, ids = { own: new Set(), mates: new Set() }) {
}
// Dynamic PVP's zones (§14.3.3): an older plugin's answer has no `pvp`, and it is empty.
if (acc.layers.pvp.visible) out.pvp = Array.isArray(live.pvp) ? live.pvp : []
// RaidableBases' bases (§11.4): an older plugin's answer has none. A run's key stays off the map.
if (acc.layers.raids.visible) out.raids = Array.isArray(live.raids) ? live.raids.map(withoutKey) : []
if (acc.layers.bases.visible) {
out.bases = Array.isArray(live.bases) ? live.bases : []
if (live.basesTruncated) out.basesTruncated = true

View File

@@ -305,10 +305,41 @@ async function gcReports() {
)
}
/**
* What one server's last status said about RaidableBases, its raids helper and
* its console (protocol 14, PLAN_REDESIGNS §11.4): `{ raidableBases, console }`,
* as `dtReportFor`'s are. Null for a server with no state yet.
*/
async function rbReportFor(serverId) {
const rows = await core.query(
`SELECT JSON_EXTRACT(raw, '$.integrations.raidableBases') AS raidableBases,
JSON_EXTRACT(raw, '$.console') AS console
FROM ${STATE}
WHERE server_id = ?`,
[serverId],
)
return rows[0] || null
}
/** `rbReportFor` for every enabled server, with its id and name: the names a step offers. */
async function rbReports() {
return core.query(
`SELECT s.id AS serverId, s.name AS name,
JSON_EXTRACT(st.raw, '$.integrations.raidableBases') AS raidableBases,
JSON_EXTRACT(st.raw, '$.console') AS console
FROM ${SERVERS} s
JOIN ${STATE} st ON st.server_id = s.id
WHERE s.enabled = 1
ORDER BY s.sort_order ASC, s.id ASC`,
)
}
module.exports = {
SERVERS,
STATE,
dtReportFor,
rbReportFor,
rbReports,
gcReportFor,
gcReports,
listServers,

View File

@@ -23,7 +23,7 @@ const crypto = require('node:crypto')
* conditions and their shipped titles, the richest (§11.2.2, Magnate), the
* two world-event counts (§14.3.1, Safecracker and Scavenger), Dangerous
* Treasures won (§14.3.4, Treasure Hunter), guarded crates cleared (§14.3.5,
* Warden), plus
* Warden), RaidableBases bases completed (§11.4, Warlord), plus
* `playtime`, which predates them and has no default title, so a playtime rule
* always carries its own text.
*
@@ -75,6 +75,8 @@ const STATS = {
treasureswon: { label: 'Dangerous Treasures won', title: 'Treasure Hunter', source: { sum: 'treasures_won' } },
// Protocol 14, Guarded Crate (D375): a crate counts for the player who killed its last guard.
guardedwon: { label: 'Guarded crates cleared', title: 'Warden', source: { sum: 'guarded_won' } },
// Protocol 14, RaidableBases (§11.4, D202): a base counts for each of the plugin's own raiders when it is completed.
raidscompleted: { label: 'Raid bases completed', title: 'Warlord', source: { sum: 'raids_completed' } },
richest: { label: 'Richest (Economics)', title: 'Magnate', source: { balance: 'balance' } },
playtime: { label: 'Playtime', title: null, source: { sum: 'playtime_sec' } },
profilekills: { label: 'Kills of an NPC profile', title: null, source: { npcProfile: true } },