import test from 'node:test'; import assert from 'node:assert/strict'; import { bestAffordableMarketUpgrade, buyAndInstallModule, collectSalvage, createStarterProgression, deriveShipStats, installModule, salvageForPirate, } from '../src/progression/ship-loadout.js'; test('starter loadout preserves current ship combat and handling values', () => { const progression = createStarterProgression(); const stats = deriveShipStats(progression.loadout); assert.equal(stats.maxHull, 100); assert.equal(stats.maxSpeed, 180); assert.equal(stats.turnRate, 76); assert.equal(stats.reloadMs, 850); assert.equal(stats.cannonDamage, 16); }); test('installed modules derive meaningful ship stat changes', () => { const progression = installModule(createStarterProgression(), 'corsair-overdrive'); const stats = deriveShipStats(progression.loadout); assert.equal(stats.maxSpeed, 214); assert.equal(stats.acceleration, 110); assert.equal(stats.turnRate, 71); }); test('port purchase deducts credits and installs the module', () => { const starter = createStarterProgression(); const result = buyAndInstallModule(starter, 'tuned-propellers'); assert.equal(result.purchased, true); assert.equal(result.credits, starter.credits - 280); assert.equal(result.loadout.engine, 'tuned-propellers'); }); test('pirate salvage is deterministic and collectible within salvage capacity', () => { const salvageA = salvageForPirate({ seed: 'WORLD', classKey: 'captain', wave: 4, sequence: 2 }); const salvageB = salvageForPirate({ seed: 'WORLD', classKey: 'captain', wave: 4, sequence: 2 }); assert.deepEqual(salvageA, salvageB); const starter = createStarterProgression(); const collected = collectSalvage(starter, salvageA); assert.ok(collected.credits >= starter.credits); assert.ok(collected.scrap >= starter.scrap); }); test('market can select an affordable upgrade for a port', () => { const starter = createStarterProgression(); const upgrade = bestAffordableMarketUpgrade(starter, { type: 'military' }); assert.ok(upgrade); assert.ok(upgrade.price <= starter.credits); });