Phase 4: close loot/refund leaks, landing-site garrisons, speed-scaled shipping, update/offsite tooling, broad e2e
Built: - Economy: raid loot capped to the room the raiders have at home (rest stays with the victim, "lootLeft" in the report); trade escrow reserves its room so refunds always fit; trade accept refuses with no_room_for_goods when the goods would not fit. Loot destroyed per 30-day run 31-61k -> ~1k, refunds clipped ~27k -> 0 (docs/BALANCE.md, 3 seeds). - End game: members of the holding alliance garrison landing sites (migration 005_site_garrison.sql), garrison counts in site defence, 72 h capture shield, withdraw route, POP view lists garrisoned units. Shipping capacity scales with world speed (3x world: winner 76-98 -> ~30-36 days after sites open). Bot runs show real contests (84-194 attacks on held sites at 1x). - Ops: deploy/update.sh (backup, stop, ff-merge, npm ci --ignore-scripts, health check, rollback), deploy/upstream-offsite (rsync only), admin end-world snapshots results, EPIPE fix, docs/workflows/ filled in. - e2e 62 -> 163 checks: units, raids/reports, alliance+messages, trade, end game, nb, PWA, reconnect, slow polling fallback (opt-in). Two app bugs found: message push ignored, "New" button stayed English. Tested: npm test 274/274, openapi check, npm run e2e 163/163 (137 s), bot runs 50x30d seeds 1-3 and 140-day/60-day speed-3 end-game runs INVARIANTS OK, adversarial review pass (findings fixed or documented). NOT tested: update.sh on a real box (systemd, real npm, runuser; stubs only, shellcheck not installed), garrison card/loot text on a phone, Node 22.13, humans. Known leaks left open and documented (BALANCE S6): loot/shipments can still overflow when stock arrives in flight, bounced backbone shipments lose overflow (reported to the sender). Garrison numbers (heldDefenceMult 2, shield 72 h) are first guesses from 2 seeds. Not claimed: balanced. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
9104480463
commit
3c23c51902
92 changed files with 4887 additions and 300 deletions
|
|
@ -5,8 +5,9 @@
|
|||
* Representation (DECISIONS.md E1): a landing site is NOT a POP. It is a row of `landing_sites` (position from the world seed,
|
||||
* holder alliance, node level, stockpile, build in progress). The tile reads 'backbone' (rules.tileAt with the world age) from
|
||||
* D.ENDGAME.openDay on; before that it is plain land that nobody may settle or spawn on. A site is defended by a static value
|
||||
* only (rules.backboneDefence: incumbent defence x defenceMult, + a bonus per node level), so there are no reinforcements at a
|
||||
* site. Holders keep the level when the site is taken; the stockpile and a running build stay with the site as well.
|
||||
* (rules.backboneDefence: incumbent defence x defenceMult while nobody holds it, x heldDefenceMult once an alliance does, + a bonus per node
|
||||
* level) PLUS the garrison its holders station there (server/military/garrison.js, DECISIONS E6). The level stays with the site when it is
|
||||
* taken; the stockpile and a running build stay with the site as well.
|
||||
*
|
||||
* Time: world age is in world days (real days x speed). Everything here takes `now` (ms) from the caller.
|
||||
*/
|
||||
|
|
@ -61,7 +62,7 @@ function siteView(db, world, s, row) {
|
|||
id: row ? row.id : null, index: s.index, x: s.x, y: s.y,
|
||||
holder: row ? allianceInfo(db, row.holder_alliance_id) : null,
|
||||
takenBy: row ? opBrief(db, row.holder_operator_id) : null, takenAt: row ? row.taken_at : null,
|
||||
level, maxLevel: E.maxLevel, progress: level / E.maxLevel, pool, build,
|
||||
level, maxLevel: E.maxLevel, progress: level / E.maxLevel, pool, build, shieldUntil: row && shieldUntil(row, world) || null,
|
||||
next: level < E.maxLevel ? { toLevel: level + 1, cost: R.backboneCost(level + 1), durationMs: R.backboneTimeMs(level + 1, world.speed) } : null,
|
||||
};
|
||||
}
|
||||
|
|
@ -121,14 +122,31 @@ function notifyWorld(ctx, worldId, type, payload) {
|
|||
|
||||
// ---------------------------------------------------------------- taking a site, winning, the end
|
||||
|
||||
// Sending checks (sendMovement): landing sites can be scanned and attacked, nothing else. Attacking needs an alliance; you cannot
|
||||
// attack a site your own alliance or a pact partner holds.
|
||||
// Sending checks (sendMovement): landing sites can be scanned and attacked, and reinforced by members of the alliance that holds them;
|
||||
// nothing else. Attacking needs an alliance; you cannot attack a site your own alliance or a pact partner holds.
|
||||
function checkLandingTarget(db, world, op, tgt, type, now, ctx) {
|
||||
if (type !== 'scan' && type !== 'attack') throw new GameError('invalid_target', { reason: 'landing_scan_or_attack_only' });
|
||||
if (type !== 'attack') return;
|
||||
if (!op.alliance_id) throw new GameError('invalid_target', { reason: 'no_alliance' });
|
||||
const row = ensureSites(db, world, now, ctx).find((r) => r.idx === tgt.tile.site);
|
||||
denyIfFriendly(db, op, row);
|
||||
const until = shieldUntil(row, world);
|
||||
if (until > now) throw new GameError('invalid_target', { reason: 'site_shielded', until });
|
||||
}
|
||||
// A site that changed hands is shielded for D.ENDGAME.captureShieldHours (E6): its new holders need time to garrison it. 0 = not shielded (unheld sites never are).
|
||||
function shieldUntil(row, world) {
|
||||
return row && row.holder_alliance_id && row.taken_at ? R.siteShieldUntil(row.taken_at, world.speed) : 0;
|
||||
}
|
||||
// Reinforcing a landing site (the garrison, E6): members of the holding alliance only. Checked again when the units arrive.
|
||||
function checkLandingReinforce(db, world, op, tgt, now, ctx) {
|
||||
const row = ensureSites(db, world, now, ctx).find((r) => r.idx === tgt.tile.site);
|
||||
if (!op.alliance_id || !row || !row.holder_alliance_id || row.holder_alliance_id !== op.alliance_id) throw new GameError('invalid_target', { reason: 'not_holder' });
|
||||
}
|
||||
// Tell the holders that something is on its way to their site (the type is hidden, like `incoming` for a POP). Nothing for an unheld site.
|
||||
function notifyLandingIncoming(ctx, world, tgt, op, mv) {
|
||||
const row = siteAt(ctx.db, world.id, tgt.tile.site);
|
||||
if (!row || !row.holder_alliance_id || row.holder_alliance_id === op.alliance_id) return;
|
||||
notifyAlliance(ctx, row.holder_alliance_id, 'backbone_incoming', { siteId: row.id, index: row.idx, x: row.x, y: row.y, arriveAt: mv.arriveAt });
|
||||
}
|
||||
function denyIfFriendly(db, op, row) {
|
||||
if (!row || !row.holder_alliance_id) return;
|
||||
|
|
@ -163,7 +181,10 @@ function maybeWin(ctx, site, now) {
|
|||
}
|
||||
|
||||
// An alliance is gone: its sites are the incumbent's again (the level stays with the site).
|
||||
function onAllianceDissolved(ctx, allianceId) {
|
||||
function onAllianceDissolved(ctx0, allianceId) {
|
||||
const ctx = require('./military/ctx')(ctx0);
|
||||
const G = require('./military/garrison');
|
||||
for (const s of ctx.db.all('SELECT * FROM landing_sites WHERE holder_alliance_id = ?', allianceId)) G.releaseSite(ctx, s, 'alliance_dissolved'); // the garrison goes home
|
||||
ctx.db.run('UPDATE landing_sites SET holder_alliance_id = NULL WHERE holder_alliance_id = ?', allianceId);
|
||||
}
|
||||
|
||||
|
|
@ -188,5 +209,5 @@ function deliverShipment(ctx, mv, now) {
|
|||
|
||||
module.exports = {
|
||||
DAY, ageDays, phase, isOpen, ensureSites, siteRow, siteAt, siteStates, siteView, allianceInfo, opBrief, winnerView, statusView,
|
||||
guard, worldOfCommand, notifyAlliance, notifyWorld, checkLandingTarget, denyIfFriendly, transferSite, maybeWin, onAllianceDissolved, deliverShipment,
|
||||
guard, worldOfCommand, notifyAlliance, notifyWorld, checkLandingTarget, shieldUntil, checkLandingReinforce, notifyLandingIncoming, denyIfFriendly, transferSite, maybeWin, onAllianceDissolved, deliverShipment,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue