Built: - Economy: raid loot capped to the room the raiders have at home (rest stays with the victim, "lootLeft" in the report); trade escrow reserves its room so refunds always fit; trade accept refuses with no_room_for_goods when the goods would not fit. Loot destroyed per 30-day run 31-61k -> ~1k, refunds clipped ~27k -> 0 (docs/BALANCE.md, 3 seeds). - End game: members of the holding alliance garrison landing sites (migration 005_site_garrison.sql), garrison counts in site defence, 72 h capture shield, withdraw route, POP view lists garrisoned units. Shipping capacity scales with world speed (3x world: winner 76-98 -> ~30-36 days after sites open). Bot runs show real contests (84-194 attacks on held sites at 1x). - Ops: deploy/update.sh (backup, stop, ff-merge, npm ci --ignore-scripts, health check, rollback), deploy/upstream-offsite (rsync only), admin end-world snapshots results, EPIPE fix, docs/workflows/ filled in. - e2e 62 -> 163 checks: units, raids/reports, alliance+messages, trade, end game, nb, PWA, reconnect, slow polling fallback (opt-in). Two app bugs found: message push ignored, "New" button stayed English. Tested: npm test 274/274, openapi check, npm run e2e 163/163 (137 s), bot runs 50x30d seeds 1-3 and 140-day/60-day speed-3 end-game runs INVARIANTS OK, adversarial review pass (findings fixed or documented). NOT tested: update.sh on a real box (systemd, real npm, runuser; stubs only, shellcheck not installed), garrison card/loot text on a phone, Node 22.13, humans. Known leaks left open and documented (BALANCE S6): loot/shipments can still overflow when stock arrives in flight, bounced backbone shipments lose overflow (reported to the sender). Garrison numbers (heldDefenceMult 2, shield 72 h) are first guesses from 2 seeds. Not claimed: balanced. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
47 lines
3.6 KiB
JavaScript
47 lines
3.6 KiB
JavaScript
'use strict';
|
|
/* End game: the race (world status), the final results, landing sites (read, feed the stockpile, build the node). Taking a site is
|
|
* POST /movements (scan / attack at its x,y). */
|
|
const { reply } = require('../http');
|
|
const { createEndgameQueries } = require('../endgameQueries');
|
|
const D = require('../../public/js/data.js');
|
|
|
|
function register(router, services) {
|
|
const { commands } = services;
|
|
const eg = createEndgameQueries(services);
|
|
const errs = ['unauthorized', 'not_found', 'validation_failed'];
|
|
|
|
router.get('/worlds/:id/status', {
|
|
summary: 'The state of the world: phase (running, backbone_open, ended), world age, the landing sites with holder, node level, stockpile and build progress, the winner', tag: 'world',
|
|
response: { $ref: 'WorldStatus' }, errors: errs,
|
|
}, ({ user, params }) => eg.status(user.id, params.id));
|
|
|
|
router.get('/worlds/:id/results', {
|
|
summary: 'The final ranking snapshot (operators, alliances, attackers, defenders, winner); available once the world has ended', tag: 'world',
|
|
response: { $ref: 'WorldResults' }, errors: errs,
|
|
}, ({ user, params }) => eg.results(user.id, params.id));
|
|
|
|
router.get('/backbone/:id', {
|
|
summary: 'One landing site; members of the holding alliance also see the contribution ledger and what they may do', tag: 'world',
|
|
response: { $ref: 'LandingSiteResponse' }, errors: errs,
|
|
}, ({ user, params }) => eg.site(user.id, params.id));
|
|
|
|
router.post('/backbone/:id/ship', {
|
|
summary: 'Send resources from one of your POPs to a landing site your alliance holds (a transport: Internet exchange links, 1000 each at world speed 1, times the world speed)', tag: 'world', status: 201,
|
|
body: { type: 'object', required: ['fromTownId', 'cargo'], properties: { fromTownId: { type: 'integer', minimum: 1 }, cargo: { type: 'object', additionalProperties: true, description: 'fiber/hardware/capital -> amount' } } },
|
|
response: { $ref: 'MovementSent' },
|
|
errors: errs.concat(['forbidden', 'backbone_closed', 'capacity_exceeded', 'no_transport_link', 'not_enough_resources', 'world_ended']),
|
|
}, ({ user, params, body }) => reply(201, commands.run('backboneShip', { userId: user.id, siteId: params.id, fromTownId: body.fromTownId, cargo: body.cargo })));
|
|
|
|
router.post('/backbone/:id/withdraw', {
|
|
summary: 'Call units of one of your POPs home from a landing site\'s garrison (default: all of them). Only their owner can; works whoever holds the site now. Station units with POST /movements type reinforce at the site\'s x,y (members of the holding alliance only)', tag: 'world', status: 201,
|
|
body: { type: 'object', required: ['fromTownId'], properties: { fromTownId: { type: 'integer', minimum: 1 }, units: { type: 'object', additionalProperties: true, description: 'defaults to the whole group' } } },
|
|
response: { $ref: 'GarrisonWithdrawn' }, errors: errs.concat(['not_enough_units', 'unknown_unit', 'conflict', 'world_ended']),
|
|
}, ({ user, params, body }) => reply(201, commands.run('withdrawGarrison', { userId: user.id, siteId: params.id, fromTownId: body.fromTownId, units: body.units })));
|
|
|
|
router.post('/backbone/:id/build', {
|
|
summary: 'Start the next Backbone node level on a landing site your alliance holds (paid from the site\'s stockpile; one level at a time, up to level ' + D.ENDGAME.maxLevel + ')', tag: 'world', status: 201,
|
|
response: { $ref: 'BackboneBuildStarted' },
|
|
errors: errs.concat(['forbidden', 'backbone_closed', 'max_level', 'already_queued', 'not_enough_resources', 'world_ended']),
|
|
}, ({ user, params }) => reply(201, commands.run('backboneBuild', { userId: user.id, siteId: params.id })));
|
|
}
|
|
module.exports = { register };
|