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
|
|
@ -174,10 +174,11 @@ test('trade: an offer expires after its ttl (divided by world speed) and returns
|
|||
|
||||
test('trade: a delivery above the receiver\'s storage cap loses exactly the overflow (and says so); the rest is conserved', () => {
|
||||
const { h, a, b } = traders({ bInfra: { rack_hall: 1 } }); // cap 1000
|
||||
h.db.run('UPDATE towns SET fiber = 900 WHERE id = ?', b.townId);
|
||||
const before = total(h);
|
||||
h.db.run('UPDATE towns SET fiber = 500 WHERE id = ?', b.townId);
|
||||
const offer = post(h, a, a.townId);
|
||||
const acc = h.run('tradeAccept', { userId: b.userId, offerId: offer.id, townId: b.townId });
|
||||
const acc = h.run('tradeAccept', { userId: b.userId, offerId: offer.id, townId: b.townId }); // room for the 400 at accept time ...
|
||||
h.db.run('UPDATE towns SET fiber = 900 WHERE id = ?', b.townId); // ... but the hall fills up on the road
|
||||
const before = total(h);
|
||||
h.advanceTo(acc.arriveAt);
|
||||
assert.equal(stock(h, b.townId).fiber, 1000);
|
||||
const arrived = T.notes(h, b.userId, 'transport_arrived')[0];
|
||||
|
|
@ -186,6 +187,22 @@ test('trade: a delivery above the receiver\'s storage cap loses exactly the over
|
|||
assert.equal(h.db.get('SELECT status FROM trade_offers WHERE id = ?', offer.id).status, 'completed');
|
||||
});
|
||||
|
||||
test('trade: accepting into a hall with no room for the goods is refused up front (no_room_for_goods); cargo already on its way counts', () => {
|
||||
const { h, a, b } = traders({ bInfra: { rack_hall: 1 } }); // cap 1000
|
||||
h.db.run('UPDATE towns SET fiber = 900 WHERE id = ?', b.townId);
|
||||
const offer = post(h, a, a.townId); // gives 400 fiber
|
||||
const before = total(h);
|
||||
const e = err(() => h.run('tradeAccept', { userId: b.userId, offerId: offer.id, townId: b.townId }));
|
||||
assert.equal(e.code, 'no_room_for_goods');
|
||||
assert.equal(e.details.room, 100);
|
||||
assert.equal(h.db.get('SELECT status FROM trade_offers WHERE id = ?', offer.id).status, 'open');
|
||||
assert.equal(h.db.get("SELECT COUNT(*) AS n FROM movements WHERE status = 'out'").n, 0, 'rolled back: no payment left either');
|
||||
assert.equal(total(h), before);
|
||||
h.db.run('UPDATE towns SET fiber = 500 WHERE id = ?', b.townId);
|
||||
h.db.run("INSERT INTO movements (world_id, owner_id, type, from_town_id, to_town_id, from_x, from_y, to_x, to_y, units, cargo, depart_at, arrive_at, status, extra, created_at) SELECT world_id, owner_id, 'transport', id, id, x, y, x, y, '{}', '{\"fiber\":200}', 0, 9e15, 'out', '{}', 0 FROM towns WHERE id = ?", b.townId);
|
||||
assert.equal(err(() => h.run('tradeAccept', { userId: b.userId, offerId: offer.id, townId: b.townId })).code, 'no_room_for_goods', '500 + 200 on its way + 400 > 1000');
|
||||
});
|
||||
|
||||
test('trade: a POP that changes hands voids its open offers; the escrow stays in the POP', () => {
|
||||
const { h, a, b } = traders();
|
||||
const offer = post(h, a, a.townId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue