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
23
server/commands/backboneShip.js
Normal file
23
server/commands/backboneShip.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
/*
|
||||
* POST /backbone/:id/ship {fromTownId, cargo}: send resources from one of your POPs to a landing site your alliance holds, to
|
||||
* feed its stockpile. A normal transport (same links, 500 per link, 12 tiles/h) whose target is the site's tile; on arrival it is
|
||||
* added to the stockpile if the sender's alliance still holds the site, otherwise it rides home.
|
||||
*/
|
||||
const { GameError } = require('../errors');
|
||||
const { settle } = require('../state');
|
||||
const { ownedTown } = require('./build');
|
||||
const { launchTransport } = require('./sendTransport');
|
||||
const { holderContext } = require('./backboneBuild');
|
||||
const ctxOf = require('../military/ctx');
|
||||
|
||||
module.exports = function backboneShip(ctx0, { userId, siteId, fromTownId, cargo }) {
|
||||
const ctx = ctxOf(ctx0);
|
||||
const { db, now } = ctx;
|
||||
const { site } = holderContext(db, userId, siteId, now);
|
||||
const from = ownedTown(db, userId, fromTownId);
|
||||
if (from.worldId !== site.world_id) throw new GameError('not_found', { what: 'town' });
|
||||
settle(db, from, now);
|
||||
const mv = launchTransport(ctx, from, { x: site.x, y: site.y }, cargo || {}, { siteId: site.id });
|
||||
return { movementId: mv.id, type: 'transport', siteId: site.id, fromTownId: from.id, toTownId: null, to: { x: site.x, y: site.y }, cargo: mv.cargo, departAt: mv.departAt, arriveAt: mv.arriveAt };
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue