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
23 lines
1.3 KiB
JavaScript
23 lines
1.3 KiB
JavaScript
'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 };
|
|
};
|