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
15 lines
790 B
JavaScript
15 lines
790 B
JavaScript
'use strict';
|
|
/* DELETE /diplomacy/proposals/:proposalId. The proposing alliance withdraws it. Needs `diplomacy`. */
|
|
const { GameError } = require('../errors');
|
|
const A = require('../alliances');
|
|
|
|
module.exports = function diploWithdraw(ctx, { userId, proposalId }) {
|
|
const { db, now } = ctx;
|
|
const p = db.get('SELECT * FROM alliance_proposals WHERE id = ?', proposalId);
|
|
if (!p) throw new GameError('not_found', { what: 'proposal' });
|
|
A.requireRole(db, userId, p.from_id, 'diplomacy');
|
|
if (p.status === 'withdrawn') return { changed: false };
|
|
if (p.status !== 'pending') throw new GameError('conflict', { what: 'proposal is ' + p.status });
|
|
db.run("UPDATE alliance_proposals SET status = 'withdrawn', answered_at = ? WHERE id = ?", now, p.id);
|
|
return { changed: true };
|
|
};
|