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
12 lines
730 B
JavaScript
12 lines
730 B
JavaScript
'use strict';
|
|
/* A research level finished. Payload { unit, stat, toLevel, userId }. Idempotent: a level never goes down. */
|
|
const R = require('../../public/js/rules.js');
|
|
|
|
module.exports = function researchDone(ctx, ev) {
|
|
const { db } = ctx;
|
|
const { unit, stat, toLevel, userId } = ev.payload;
|
|
if (!db.get('SELECT 1 AS x FROM towns WHERE id = ?', ev.townId)) return;
|
|
db.run(`INSERT INTO town_research (town_id, unit, stat, level) VALUES (?, ?, ?, ?)
|
|
ON CONFLICT (town_id, unit, stat) DO UPDATE SET level = MAX(level, excluded.level)`, ev.townId, unit, stat, toLevel);
|
|
if (userId) ctx.notify(userId, ev.worldId, 'research_done', { townId: ev.townId, unit, stat, level: toLevel, key: R.researchKey(unit, stat) });
|
|
};
|