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
15
server/commands/tradeCancel.js
Normal file
15
server/commands/tradeCancel.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
'use strict';
|
||||
/* DELETE /trade/offers/:id: take your open offer back; the escrow returns to the POP. */
|
||||
const { GameError } = require('../errors');
|
||||
const ctxOf = require('../military/ctx');
|
||||
const T = require('../trade');
|
||||
|
||||
module.exports = function tradeCancel(ctx0, { userId, offerId }) {
|
||||
const ctx = ctxOf(ctx0);
|
||||
const { db, now } = ctx;
|
||||
const o = T.getOffer(db, offerId);
|
||||
if (!o || T.userOfOperator(db, o.operator_id) !== userId) throw new GameError('not_found', { what: 'offer' });
|
||||
if (o.status !== 'open') throw new GameError('offer_closed', { status: o.status });
|
||||
T.closeOffer(ctx, o, 'cancelled', now);
|
||||
return { offerId: o.id, status: 'cancelled', returned: { resource: o.give_res, amount: o.give_amount } };
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue