Phase 2: client military/social screens, WebSocket push, trade + endgame, review findings pending
Built: units/movements/reports/send/expansion screens, alliance/messages/rankings screens, ws client + server /ws push (docs/PROTOCOL.md), Internet exchange trade, backbone endgame + world end, shared reports, buildDone relative levels. Tested: npm test 175/175. Two adversarial reviews found issues (trade-leg recall exploit, __proto__ via validate.js, rankings DoS, static headers, ...): fixes follow in the next commit. NOT done: bots/balance, e2e suite, real-device checks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
249818a7aa
commit
b18645dca1
87 changed files with 10201 additions and 71 deletions
22
server/events/backboneDone.js
Normal file
22
server/events/backboneDone.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
/* A Backbone node level finished. Payload { siteId, toLevel, by }. Idempotent: only acts while the site's build points at THIS
|
||||
* event. The level lands on the SITE (a capture during the build does not stop it); level maxLevel makes the holder alliance the
|
||||
* winner (once per world) and schedules the end of the world. */
|
||||
const D = require('../../public/js/data.js');
|
||||
const { loadWorld } = require('../state');
|
||||
const E = require('../endgame');
|
||||
|
||||
module.exports = function backboneDone(ctx, ev) {
|
||||
const { db } = ctx;
|
||||
const site = E.siteRow(db, ev.payload.siteId);
|
||||
if (!site || site.build_event_id !== ev.id) return;
|
||||
const world = loadWorld(db, site.world_id);
|
||||
if (!world || world.status === 'ended') return;
|
||||
const level = site.build_to;
|
||||
db.run('UPDATE landing_sites SET level = ?, build_to = NULL, build_event_id = NULL, build_started_at = NULL, build_due_at = NULL, build_cost = NULL WHERE id = ?', level, site.id);
|
||||
const fresh = E.siteRow(db, site.id);
|
||||
if (fresh.holder_alliance_id && (level % D.ENDGAME.notifyEvery === 0 || level >= D.ENDGAME.maxLevel)) {
|
||||
E.notifyAlliance(ctx, fresh.holder_alliance_id, 'backbone_level', { siteId: site.id, index: site.idx, level });
|
||||
}
|
||||
E.maybeWin(ctx, fresh, ev.dueAt);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue