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
720 B
JavaScript
15 lines
720 B
JavaScript
'use strict';
|
|
/* A unilateral cancel of a pact (or war declared out of a pact) came due. Payload { a, b, to, by }.
|
|
* Idempotent and safe against cancellation: it only acts when the relation row still points at THIS event. */
|
|
const A = require('../alliances');
|
|
const Dip = require('../diplomacy');
|
|
|
|
module.exports = function diploChange(ctx, ev) {
|
|
const { db } = ctx;
|
|
const { a, b, to } = ev.payload;
|
|
const rel = A.getRelation(db, a, b);
|
|
if (!rel || rel.pending_event !== ev.id) return; // revoked, replaced, or already applied
|
|
const x = A.getAlliance(db, a), y = A.getAlliance(db, b);
|
|
if (!x || !y) return;
|
|
Dip.applyChange(ctx, x, y, to, { delayed: true, startedBy: ev.payload.by });
|
|
};
|