Stage 3-5 server (military, expansion, social), web client for stages 1-2, ops/deploy
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
This commit is contained in:
parent
b56b13880e
commit
249818a7aa
111 changed files with 17472 additions and 13 deletions
25
server/diplomacy.js
Normal file
25
server/diplomacy.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
/* Shared pieces of the diplomacy commands and the delayed `diploChange` event. */
|
||||
const A = require('./alliances');
|
||||
|
||||
const brief = (a) => ({ id: a.id, tag: a.tag, name: a.name });
|
||||
|
||||
// Everybody in both alliances hears about a relation that changed.
|
||||
function announceChange(ctx, x, y, from, to, extra) {
|
||||
for (const [me, other] of [[x, y], [y, x]]) {
|
||||
A.notifyAlliance(ctx, me.id, 'diplomacy_changed', Object.assign({ allianceId: me.id, other: brief(other), from, to }, extra || {}));
|
||||
}
|
||||
}
|
||||
|
||||
// Make `to` the current relation of the pair right now, drop proposals that this overtakes, tell everyone.
|
||||
function applyChange(ctx, x, y, to, extra) {
|
||||
const { db, now } = ctx;
|
||||
const cur = A.getRelation(db, x.id, y.id);
|
||||
const from = cur ? cur.state : 'neutral';
|
||||
A.setRelation(db, x.world_id, x.id, y.id, to, now);
|
||||
A.withdrawProposals(db, x.id, y.id, now);
|
||||
announceChange(ctx, x, y, from, to, extra);
|
||||
return from;
|
||||
}
|
||||
|
||||
module.exports = { brief, announceChange, applyChange };
|
||||
Loading…
Add table
Add a link
Reference in a new issue