Stage 3-5 server (military, expansion, social), web client for stages 1-2, ops/deploy
Built: units/research/training, movements (scan, raid, attack, takeover, reinforce, settle, transport), deterministic combat resolved in the event queue, reports, power/offline units, founding + conquest + incumbent sites; alliances, roles, diplomacy (24h pact cancel via events), messages, rankings; vanilla-JS phone-first client (auth, POP, map, alerts, settings, en/nb); systemd units, backup timer, DEPLOY.md, tools/admin.js. Tested: npm test 96/96 (fake clock, in-memory db, a few real-HTTP tests); client checked with headless Chromium screenshots only. NOT done: marketplace/transport trade, client screens for military/social, WebSocket push, bots/balance, e2e suite. All unit stats and costs are unbalanced first guesses. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
b56b13880e
commit
249818a7aa
111 changed files with 17472 additions and 13 deletions
21
server/routes/units.js
Normal file
21
server/routes/units.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
/* Training queue and research of a POP (stage 3). */
|
||||
const { reply } = require('../http');
|
||||
const D = require('../../public/js/data.js');
|
||||
|
||||
function register(router, { commands }) {
|
||||
const errs = ['unauthorized', 'not_found', 'validation_failed'];
|
||||
|
||||
router.post('/towns/:id/train', {
|
||||
summary: 'Queue a batch of one unit type. Batches of the same training building run in order; units appear when the batch is done', tag: 'units',
|
||||
body: { type: 'object', required: ['unit', 'count'], properties: { unit: { type: 'string', maxLength: 32, pattern: '^[a-z_]+$' }, count: { type: 'integer', minimum: 1, maximum: D.MILITARY.maxBatch } } },
|
||||
response: { $ref: 'TrainResult' }, status: 201, errors: errs.concat(['unknown_unit', 'requirements_not_met', 'not_enough_resources', 'queue_full']),
|
||||
}, ({ user, params, body }) => reply(201, commands.run('train', { userId: user.id, townId: params.id, unit: body.unit, count: body.count })));
|
||||
|
||||
router.post('/towns/:id/research', {
|
||||
summary: 'Research +5% attack or defence for one unit type (one research at a time per POP, needs a Research lab)', tag: 'units',
|
||||
body: { type: 'object', required: ['unit', 'stat'], properties: { unit: { type: 'string', maxLength: 32, pattern: '^[a-z_]+$' }, stat: { type: 'string', enum: ['attack', 'defence'] } } },
|
||||
response: { $ref: 'ResearchResult' }, status: 201, errors: errs.concat(['unknown_unit', 'not_researchable', 'max_level', 'requirements_not_met', 'not_enough_resources', 'queue_full']),
|
||||
}, ({ user, params, body }) => reply(201, commands.run('research', { userId: user.id, townId: params.id, unit: body.unit, stat: body.stat })));
|
||||
}
|
||||
module.exports = { register };
|
||||
Loading…
Add table
Add a link
Reference in a new issue