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
|
|
@ -29,6 +29,7 @@ const schemas = {
|
|||
power: obj({ out: num, draw: num, net: num, buffer: num, bufferCap: num, bufferRate: num, online: bool }),
|
||||
buildings: arr({ $ref: 'BuildingView' }), queue: arr({ $ref: 'QueueEntry' }), queueSlots: int,
|
||||
bonus: obj({ fiber: num, hardware: num, capital: num }),
|
||||
escrow: obj({ fiber: num, hardware: num, capital: num }), // goods in open Internet exchange offers: they still occupy the Rack hall (resources[r].cap already excludes them)
|
||||
}),
|
||||
TownResponse: obj({ serverTime: int, town: { $ref: 'Town' } }),
|
||||
MapTown: obj({ id: int, name: str, x: int, y: int, isCapital: bool, owner: obj({ id: int, name: str, asNumber: int, allianceId: { type: ['integer', 'null'] }, alliance: { type: ['object', 'null'], properties: { id: int, tag: str, name: str }, additionalProperties: true }, protected: bool }) }),
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ module.exports = function addEndgameSchemas(schemas, { int, num, str, bool, obj,
|
|||
// ---- end game
|
||||
LandingSite: obj({
|
||||
id: nint, index: int, x: int, y: int, holder: { type: ['object', 'null'], properties: { allianceId: int, tag: str, name: str }, additionalProperties: true },
|
||||
takenBy: { type: ['object', 'null'], additionalProperties: true }, takenAt: nint, level: int, maxLevel: int, progress: num, pool: Cost,
|
||||
takenBy: { type: ['object', 'null'], additionalProperties: true }, takenAt: nint, shieldUntil: nint, level: int, maxLevel: int, progress: num, pool: Cost,
|
||||
build: { type: ['object', 'null'], properties: { toLevel: int, startedAt: int, dueAt: int }, additionalProperties: true },
|
||||
next: { type: ['object', 'null'], properties: { toLevel: int, cost: Cost, durationMs: int }, additionalProperties: true },
|
||||
}),
|
||||
|
|
@ -31,9 +31,13 @@ module.exports = function addEndgameSchemas(schemas, { int, num, str, bool, obj,
|
|||
}),
|
||||
WorldResults: obj({ serverTime: int, available: bool, status: str, winner: { type: ['object', 'null'], additionalProperties: true }, endsAt: nint, results: { type: ['object', 'null'], additionalProperties: true } }),
|
||||
LandingSiteResponse: obj({
|
||||
serverTime: int, site: { $ref: 'LandingSite' }, you: obj({ holder: bool, canBuild: bool, canShip: bool, canAttack: bool }),
|
||||
serverTime: int, site: { $ref: 'LandingSite' }, you: obj({ holder: bool, canBuild: bool, canShip: bool, canAttack: bool, canReinforce: bool }),
|
||||
contributions: arr(obj({ operatorId: int, name: str, fiber: int, hardware: int, capital: int })),
|
||||
// holders only: what defends the site now (static part + the units members station there) and who owns the units
|
||||
defence: obj({ static: num, garrison: num, total: num }),
|
||||
garrison: arr(obj({ ownerTownId: int, townName: nstr, operator: { type: ['object', 'null'], additionalProperties: true }, units: { type: 'object', additionalProperties: true }, online: bool, power: num, mine: bool })),
|
||||
}, ['serverTime', 'site', 'you']),
|
||||
GarrisonWithdrawn: obj({ serverTime: int, movementId: int, siteId: int, fromTownId: int, units: { type: 'object', additionalProperties: true }, arriveAt: int }),
|
||||
BackboneBuildStarted: obj({ serverTime: int, siteId: int, eventId: int, toLevel: int, startedAt: int, dueAt: int, cost: Cost }),
|
||||
// ---- shared reports
|
||||
ReportShared: obj({ serverTime: int, changed: bool, reportId: int, allianceId: int }),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ module.exports = function addMilitarySchemas(schemas, { int, num, str, bool, obj
|
|||
settle: obj({ possible: bool, code: { type: ['string', 'null'] }, footprint: num, footprintNeeded: num, maxDistance: int }),
|
||||
}, ['serverTime', 'x', 'y', 'type', 'distances', 'settle']),
|
||||
TownMilitary: obj({
|
||||
units: obj({ home: Units, online: bool, offlineSince: nint, stationedHere: arr(free), stationedAway: arr(free) }),
|
||||
units: obj({ home: Units, online: bool, offlineSince: nint, stationedHere: arr(free), stationedAway: arr(free), garrisoned: arr(obj({ siteId: int, x: int, y: int, units: Units })) }),
|
||||
training: arr(obj({ id: int, unit: str, count: int, building: str, startAt: int, dueAt: int })),
|
||||
trainable: arr(obj({ unit: str, building: str, role: str, cost: Cost, timeMs: int, missing: arr(free), locked: bool })),
|
||||
research: obj({ levels: free, queue: { type: ['object', 'null'], additionalProperties: true }, speedBonus: num, maxLevel: int }),
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ function register(router, services) {
|
|||
summary: 'Take an open offer with one of your POPs: two transports leave at once (your payment, their goods) and the offer is settled when both arrive', tag: 'trade', status: 201,
|
||||
body: { type: 'object', required: ['townId'], properties: { townId: int1 } },
|
||||
response: { $ref: 'TradeAccepted' },
|
||||
errors: errs.concat(['offer_closed', 'own_offer', 'trade_out_of_range', 'no_transport_link', 'capacity_exceeded', 'not_enough_resources', 'world_ended']),
|
||||
errors: errs.concat(['offer_closed', 'own_offer', 'trade_out_of_range', 'no_room_for_goods', 'no_transport_link', 'capacity_exceeded', 'not_enough_resources', 'world_ended']),
|
||||
}, ({ user, params, body }) => reply(201, commands.run('tradeAccept', { userId: user.id, offerId: params.id, townId: body.townId })));
|
||||
}
|
||||
module.exports = { register };
|
||||
|
|
|
|||
|
|
@ -26,12 +26,18 @@ function register(router, services) {
|
|||
}, ({ user, params }) => eg.site(user.id, params.id));
|
||||
|
||||
router.post('/backbone/:id/ship', {
|
||||
summary: 'Send resources from one of your POPs to a landing site your alliance holds (a transport: Internet exchange links, 500 each)', tag: 'world', status: 201,
|
||||
summary: 'Send resources from one of your POPs to a landing site your alliance holds (a transport: Internet exchange links, 1000 each at world speed 1, times the world speed)', tag: 'world', status: 201,
|
||||
body: { type: 'object', required: ['fromTownId', 'cargo'], properties: { fromTownId: { type: 'integer', minimum: 1 }, cargo: { type: 'object', additionalProperties: true, description: 'fiber/hardware/capital -> amount' } } },
|
||||
response: { $ref: 'MovementSent' },
|
||||
errors: errs.concat(['forbidden', 'backbone_closed', 'capacity_exceeded', 'no_transport_link', 'not_enough_resources', 'world_ended']),
|
||||
}, ({ user, params, body }) => reply(201, commands.run('backboneShip', { userId: user.id, siteId: params.id, fromTownId: body.fromTownId, cargo: body.cargo })));
|
||||
|
||||
router.post('/backbone/:id/withdraw', {
|
||||
summary: 'Call units of one of your POPs home from a landing site\'s garrison (default: all of them). Only their owner can; works whoever holds the site now. Station units with POST /movements type reinforce at the site\'s x,y (members of the holding alliance only)', tag: 'world', status: 201,
|
||||
body: { type: 'object', required: ['fromTownId'], properties: { fromTownId: { type: 'integer', minimum: 1 }, units: { type: 'object', additionalProperties: true, description: 'defaults to the whole group' } } },
|
||||
response: { $ref: 'GarrisonWithdrawn' }, errors: errs.concat(['not_enough_units', 'unknown_unit', 'conflict', 'world_ended']),
|
||||
}, ({ user, params, body }) => reply(201, commands.run('withdrawGarrison', { userId: user.id, siteId: params.id, fromTownId: body.fromTownId, units: body.units })));
|
||||
|
||||
router.post('/backbone/:id/build', {
|
||||
summary: 'Start the next Backbone node level on a landing site your alliance holds (paid from the site\'s stockpile; one level at a time, up to level ' + D.ENDGAME.maxLevel + ')', tag: 'world', status: 201,
|
||||
response: { $ref: 'BackboneBuildStarted' },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue