feat(rust): Economics — pay coins, balances, staff adjust, the richest (PLAN_REDESIGNS §11.2)
The site half of §11.2.2, on protocol 14:
- `rust.coins.pay` ("Pay coins"): irreversible, reversible none (D335). The
recipient modes of rust.kit.entitle including `linked`, one payment per
website user (D103's rule), an optional message with {amount}, a new
`rust.coins` budget. Refused with "Economics is not installed on this
server" in the dry run too (D199). Core's key goes to the plugin, so a
retried step answers `repeat` and pays nobody twice.
- `rust_player_wipe_stats.balance`: the tally's balance, written as a value.
A nameless balance frame (an offline player) moves nobody's last-seen.
`economics.wiped` clears the wipe's balances, except at a new save.
- The richest: a Coins leaderboard column on one wipe of a server that
reports Economics, `sort=balance`, and a `richest` title category
(Magnate); both rank only above the starting balance (D336).
- GET /player/rust/economics (live, falling back to the last known), and
GET/POST /admin/users/:id/rust/economics for staff — scoped to the user's
own links, keyed per submission, an activity row with before and after.
- Client: the account page's Coins, the admin user page's Coins panel with
its form, the leaderboard column, and Economics in the server's mod line
(saying when its config could not be read).
Server 535/535 (14 new in test/economics.test.js), client 74/74,
routes.manifest regenerated against the pinned core (87 routes), swagger
fragment regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -138,6 +138,17 @@ async function apply(serverId, item, server = null) {
|
||||
}
|
||||
|
||||
case 'player.tally': {
|
||||
// Protocol 14 (§11.2.2): the player's Economics balance, a VALUE written
|
||||
// over rather than added — unlike everything below it.
|
||||
const hasBalance = frame.balance !== undefined && frame.balance !== null
|
||||
if (hasBalance) await db.setBalance(at, frame.balance)
|
||||
|
||||
// A balance with no name is an offline player's: a payment or a staff
|
||||
// adjustment reaches somebody who is not there, and the plugin names only
|
||||
// a connected player. It says nothing about play, so it must not move
|
||||
// anybody's last-seen — which every writer below does.
|
||||
if (hasBalance && !frame.name) break
|
||||
|
||||
await db.touchPlayer(frame.steamId, frame.name || null)
|
||||
await db.addStats(at, {
|
||||
npcKills: Number(frame.npcKills) || 0,
|
||||
@@ -257,6 +268,16 @@ async function apply(serverId, item, server = null) {
|
||||
break
|
||||
}
|
||||
|
||||
// ── Protocol 14: Economics wiped every balance (§11.2.2) ────────────────
|
||||
//
|
||||
// `ecowipe` puts everyone back at the start in the wipe in play, so none of
|
||||
// its balances is known any more. A new save's wipe (`newSave`) opens a new
|
||||
// map whose balances arrive as players connect; the last wipe's stay as the
|
||||
// record of how it ended.
|
||||
case 'economics.wiped':
|
||||
if (!frame.newSave) await db.clearBalances(serverId, wipeId)
|
||||
break
|
||||
|
||||
// ── Protocol 6: first-party clans ──────────────────────────────────────
|
||||
//
|
||||
// Each one is told to core as it happens (`ctx.teams.publish`) and written
|
||||
|
||||
Reference in New Issue
Block a user