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:
jvanvik 2026-10-11 18:32:36 +02:00
parent b56b13880e
commit 249818a7aa
111 changed files with 17472 additions and 13 deletions

View file

@ -0,0 +1,41 @@
'use strict';
/* Pinned notes of an alliance. Three commands, one file: allianceNoteAdd / allianceNoteEdit / allianceNoteDelete
* (registered separately in commands/index.js). Needs `editNotes`. */
const { GameError } = require('../errors');
const { cleanText } = require('../text');
const A = require('../alliances');
function text(raw) {
const t = cleanText(raw, { multiline: true });
if (!t || [...t].length > A.S.noteMax) throw new GameError('validation_failed', { errors: [{ path: 'text', message: 'must be 1-' + A.S.noteMax + ' characters of plain text' }] });
return t;
}
const view = (n) => ({ id: n.id, authorId: n.author_id, text: n.text, createdAt: n.created_at, updatedAt: n.updated_at });
function allianceNoteAdd(ctx, { userId, allianceId, text: raw }) {
const { db, now } = ctx;
const { op, alliance } = A.requireRole(db, userId, allianceId, 'editNotes');
const t = text(raw);
if (db.get('SELECT COUNT(*) AS n FROM alliance_notes WHERE alliance_id = ?', alliance.id).n >= A.S.maxNotes) throw new GameError('notes_full', { max: A.S.maxNotes });
const r = db.run('INSERT INTO alliance_notes (alliance_id, author_id, text, created_at, updated_at) VALUES (?, ?, ?, ?, ?)', alliance.id, op.id, t, now, now);
return { note: view(db.get('SELECT * FROM alliance_notes WHERE id = ?', Number(r.lastInsertRowid))) };
}
function allianceNoteEdit(ctx, { userId, allianceId, noteId, text: raw }) {
const { db, now } = ctx;
const { alliance } = A.requireRole(db, userId, allianceId, 'editNotes');
const t = text(raw);
const r = db.run('UPDATE alliance_notes SET text = ?, updated_at = ? WHERE id = ? AND alliance_id = ?', t, now, noteId, alliance.id);
if (!r.changes) throw new GameError('not_found', { what: 'note' });
return { note: view(db.get('SELECT * FROM alliance_notes WHERE id = ?', noteId)) };
}
function allianceNoteDelete(ctx, { userId, allianceId, noteId }) {
const { db } = ctx;
const { alliance } = A.requireRole(db, userId, allianceId, 'editNotes');
const r = db.run('DELETE FROM alliance_notes WHERE id = ? AND alliance_id = ?', noteId, alliance.id);
return { changed: r.changes > 0 };
}
module.exports = { allianceNoteAdd, allianceNoteEdit, allianceNoteDelete, noteView: view };