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
22 lines
1.4 KiB
JavaScript
22 lines
1.4 KiB
JavaScript
'use strict';
|
|
/* DELETE /alliances/:id/diplomacy/:otherId/pending. The alliance that started a delayed change (cancelling a pact,
|
|
* declaring war out of a pact) may take it back before it takes effect. Nothing pending: no-op. */
|
|
const { GameError } = require('../errors');
|
|
const A = require('../alliances');
|
|
const Dip = require('../diplomacy');
|
|
|
|
module.exports = function diploRevoke(ctx, { userId, allianceId, otherId }) {
|
|
const { db, now } = ctx;
|
|
const { alliance } = A.requireRole(db, userId, allianceId, 'diplomacy');
|
|
const other = A.getAlliance(db, otherId);
|
|
if (!other) throw new GameError('not_found', { what: 'alliance' });
|
|
const rel = A.getRelation(db, alliance.id, other.id);
|
|
if (!rel || !rel.pending_to) return { changed: false };
|
|
if (rel.pending_by !== alliance.id) throw new GameError('forbidden', { need: 'pending change started by your alliance' });
|
|
db.run("UPDATE events SET status = 'cancelled', done_at = ? WHERE id = ? AND status = 'pending'", now, rel.pending_event);
|
|
db.run('UPDATE alliance_relations SET pending_to = NULL, pending_at = NULL, pending_by = NULL, pending_event = NULL WHERE a_id = ? AND b_id = ?', rel.a_id, rel.b_id);
|
|
for (const [me, o2] of [[alliance, other], [other, alliance]]) {
|
|
A.notifyAlliance(ctx, me.id, 'diplomacy_cancel_revoked', { allianceId: me.id, other: Dip.brief(o2), state: rel.state });
|
|
}
|
|
return { changed: true, state: rel.state };
|
|
};
|