Phase 2: client military/social screens, WebSocket push, trade + endgame, review findings pending
Built: units/movements/reports/send/expansion screens, alliance/messages/rankings screens, ws client + server /ws push (docs/PROTOCOL.md), Internet exchange trade, backbone endgame + world end, shared reports, buildDone relative levels. Tested: npm test 175/175. Two adversarial reviews found issues (trade-leg recall exploit, __proto__ via validate.js, rankings DoS, static headers, ...): fixes follow in the next commit. NOT done: bots/balance, e2e suite, real-device checks. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
249818a7aa
commit
b18645dca1
87 changed files with 10201 additions and 71 deletions
|
|
@ -72,6 +72,8 @@ function arriveReinforce(ctx, mv, ev) {
|
|||
function arriveTransport(ctx, mv, ev) {
|
||||
const { db } = ctx;
|
||||
const now = ev.dueAt;
|
||||
// A shipment to a backbone landing site (extra.siteId) feeds the site's stockpile; refused ones ride home like any undeliverable cargo.
|
||||
const siteDelivered = !!(mv.extra && mv.extra.siteId) && require('../endgame').deliverShipment(ctx, mv, now);
|
||||
const target = mv.toTownId ? loadTown(db, mv.toTownId) : null;
|
||||
let lost = {};
|
||||
if (target) {
|
||||
|
|
@ -82,7 +84,7 @@ function arriveTransport(ctx, mv, ev) {
|
|||
if (sender && sender !== receiver) ctx.notify(sender, mv.worldId, 'transport_delivered', { movementId: mv.id, toTownId: target.id, cargo: mv.cargo, cargoLost: lost });
|
||||
for (const fn of M.hooks.transportArrived) fn(ctx, mv, { added: mv.cargo, lost });
|
||||
}
|
||||
const cargoBack = target ? {} : mv.cargo; // no such POP any more: the cargo rides home with the carriers
|
||||
const cargoBack = target || siteDelivered ? {} : mv.cargo; // no such POP any more: the cargo rides home with the carriers
|
||||
// The empty carriers drive back; the link is busy until they are home.
|
||||
const dest = U.homeTownFor(db, mv.ownerId, mv.fromTownId);
|
||||
if (dest) {
|
||||
|
|
@ -99,12 +101,12 @@ function arriveSettle(ctx, mv, ev) {
|
|||
const world = loadWorld(db, mv.worldId);
|
||||
const op = U.getOperator(db, mv.ownerId);
|
||||
const { x, y } = mv.to;
|
||||
const tile = R.tileAt(world.seed, world.map_radius, x, y);
|
||||
const tile = R.tileAt(world.seed, world.map_radius, x, y, R.worldAgeDays(world.start_at, now, world.speed));
|
||||
const occupied = !!db.get('SELECT 1 AS x FROM towns WHERE world_id = ? AND x = ? AND y = ?', world.id, x, y);
|
||||
const own = U.operatorTowns(db, op.id);
|
||||
let nearest = Infinity;
|
||||
for (const t of own) nearest = Math.min(nearest, R.distance(t.x, t.y, x, y));
|
||||
const chk = R.settleCheck({ tileType: tile.type, occupied, nearestOwnDist: nearest, ownedCount: own.length, footprint: U.operatorFootprint(db, op.id, now) });
|
||||
const chk = R.settleCheck({ tileType: tile.type, backbone: R.isBackboneSite(world.seed, world.map_radius, x, y), occupied, nearestOwnDist: nearest, ownedCount: own.length, footprint: U.operatorFootprint(db, op.id, now) });
|
||||
if (!chk.ok) return bounce(ctx, mv, now, chk.code, chk);
|
||||
const wild = R.cleanWild(mv.extra.wild);
|
||||
const name = op.name + ' POP ' + (own.length + 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue