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
45
server/routes/schemasEndgame.js
Normal file
45
server/routes/schemasEndgame.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
/* Response schemas of trade, the end game and the shared report folder (merged into routes/schemas.js). Documentation
|
||||
* only, like the others (test helpers can check them with createTestServer({ contract: true })). */
|
||||
module.exports = function addEndgameSchemas(schemas, { int, num, str, bool, obj, arr }) {
|
||||
const nint = { type: ['integer', 'null'] };
|
||||
const nstr = { type: ['string', 'null'] };
|
||||
const free = { type: 'object', additionalProperties: true };
|
||||
const Cost = { $ref: 'Cost' };
|
||||
Object.assign(schemas, {
|
||||
// ---- trade
|
||||
TradeAmount: obj({ resource: str, amount: int }),
|
||||
TradeOffer: obj({
|
||||
id: int, status: str, worldId: int, townId: int, townName: nstr, x: nint, y: nint, operator: obj({ id: int, name: nstr }),
|
||||
give: { $ref: 'TradeAmount' }, want: { $ref: 'TradeAmount' }, maxDistance: int, createdAt: int, expiresAt: int, acceptedAt: nint, closedAt: nint,
|
||||
role: str, acceptableFrom: arr(obj({ townId: int, distance: num })),
|
||||
}, ['id', 'status', 'townId', 'operator', 'give', 'want', 'maxDistance', 'createdAt', 'expiresAt']),
|
||||
TradeOfferList: obj({ serverTime: int, items: arr({ $ref: 'TradeOffer' }), next: nint, exchangeLevels: arr(obj({ townId: int, level: int, reach: num })) }, ['serverTime', 'items', 'next']),
|
||||
TradeOfferResponse: obj({ serverTime: int, offer: { $ref: 'TradeOffer' } }),
|
||||
TradeCancelled: obj({ serverTime: int, offerId: int, status: str, returned: { $ref: 'TradeAmount' } }),
|
||||
TradeAccepted: obj({ serverTime: int, offerId: int, status: str, goodsMovementId: int, paymentMovementId: int, distance: num, arriveAt: int, give: { $ref: 'TradeAmount' }, want: { $ref: 'TradeAmount' } }),
|
||||
// ---- end game
|
||||
LandingSite: obj({
|
||||
id: nint, index: int, x: int, y: int, holder: { type: ['object', 'null'], properties: { allianceId: int, tag: str, name: str }, additionalProperties: true },
|
||||
takenBy: { type: ['object', 'null'], additionalProperties: true }, takenAt: nint, level: int, maxLevel: int, progress: num, pool: Cost,
|
||||
build: { type: ['object', 'null'], properties: { toLevel: int, startedAt: int, dueAt: int }, additionalProperties: true },
|
||||
next: { type: ['object', 'null'], properties: { toLevel: int, cost: Cost, durationMs: int }, additionalProperties: true },
|
||||
}),
|
||||
WorldStatus: obj({
|
||||
serverTime: int, worldId: int, name: str, speed: num, status: str, phase: str, ageDays: num, openDay: int, opensAt: int,
|
||||
sites: arr({ $ref: 'LandingSite' }), winner: { type: ['object', 'null'], additionalProperties: true }, endsAt: nint, endedAt: nint,
|
||||
}),
|
||||
WorldResults: obj({ serverTime: int, available: bool, status: str, winner: { type: ['object', 'null'], additionalProperties: true }, endsAt: nint, results: { type: ['object', 'null'], additionalProperties: true } }),
|
||||
LandingSiteResponse: obj({
|
||||
serverTime: int, site: { $ref: 'LandingSite' }, you: obj({ holder: bool, canBuild: bool, canShip: bool, canAttack: bool }),
|
||||
contributions: arr(obj({ operatorId: int, name: str, fiber: int, hardware: int, capital: int })),
|
||||
}, ['serverTime', 'site', 'you']),
|
||||
BackboneBuildStarted: obj({ serverTime: int, siteId: int, eventId: int, toLevel: int, startedAt: int, dueAt: int, cost: Cost }),
|
||||
// ---- shared reports
|
||||
ReportShared: obj({ serverTime: int, changed: bool, reportId: int, allianceId: int }),
|
||||
SharedReportItem: obj({ id: int, type: str, createdAt: int, sharedAt: int, sharedBy: obj({ operatorId: int, name: str }), summary: free }),
|
||||
SharedReportList: obj({ serverTime: int, items: arr({ $ref: 'SharedReportItem' }), next: nint }),
|
||||
SharedReport: obj({ id: int, type: str, createdAt: int, expiresAt: int, sharedAt: int, sharedBy: obj({ operatorId: int, name: str }), summary: free, data: free }),
|
||||
SharedReportResponse: obj({ serverTime: int, report: { $ref: 'SharedReport' } }),
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue