78 lines
2.9 KiB
JavaScript
78 lines
2.9 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
bestAffordableMarketUpgrade,
|
|
buyAndInstallModule,
|
|
marketForPort,
|
|
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, false);
|
|
const funded = { ...starter, credits: 1000 };
|
|
const fundedResult = buyAndInstallModule(funded, 'tuned-propellers');
|
|
assert.equal(fundedResult.purchased, true);
|
|
assert.equal(fundedResult.credits, funded.credits - 800);
|
|
assert.equal(fundedResult.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);
|
|
});
|
|
|
|
|
|
test('rudder is stocked at every port type so the shipyard card is actionable', () => {
|
|
const portTypes = ['industrial', 'military', 'fuel', 'trade'];
|
|
for (const type of portTypes) {
|
|
const stock = marketForPort({ type });
|
|
assert.ok(stock.some(({ id }) => id === 'reinforced-rudder'));
|
|
}
|
|
});
|
|
|
|
test('rudder tier matches shipyard art and improves handling', () => {
|
|
const starter = { ...createStarterProgression(), credits: 650 };
|
|
const result = buyAndInstallModule(starter, 'reinforced-rudder');
|
|
const stats = deriveShipStats(result.loadout);
|
|
assert.equal(result.purchased, true);
|
|
assert.equal(result.credits, 250);
|
|
assert.equal(stats.turnRate, 88);
|
|
});
|