import { content, upgradeMaxLevel, upgradePercentPerLevel, upgrades } from "@deadhead/content"; import { describe, expect, it } from "vitest"; import { checkRoute, effectiveStats, realToGame, routeDistance } from "../src/index"; /** Every upgrade at its highest level for the model (decision 0.5.63). */ const maxedStats = (modelId: string) => effectiveStats( content.shipModel(modelId)!, Object.fromEntries(upgrades.map((u) => [u.id, upgradeMaxLevel(u, modelId)])), content, ); const MONTH = 30.44 * 24 * 3_600_000; const start = realToGame(Date.parse(content.config.epoch.realStart), content.config); const samples = Array.from({ length: 16 * 12 + 1 }, (_, i) => start + i * MONTH); const earth = content.location("earth")!; const moon = content.location("moon")!; const mars = content.location("mars")!; const jupiter = content.location("jupiter-cloud-platform")!; describe("upgrade caps for the CR-012 lineup (decision 0.5.67)", () => { it("a maxed Lighter never reaches Mars from Earth or the Moon", () => { const lighter = maxedStats("lighter"); for (const from of [earth, moon]) { for (const t of samples) expect(checkRoute(lighter, from, mars, t).ok).toBe(false); } }); it("a maxed Clipper carries less than a base Freighter", () => { expect(maxedStats("clipper").cargoCapacityTonnes).toBeLessThan( content.shipModel("freighter")!.cargoCapacityTonnes, ); }); it("a maxed Courier is slower than a base Clipper", () => { expect(maxedStats("courier").cruiseSpeedKmPerGameHour).toBeLessThan( content.shipModel("clipper")!.cruiseSpeedKmPerGameHour, ); }); it("only Bulk Haulers reach Jupiter from Earth at its farthest, even maxed", () => { const farthest = samples.reduce((a, b) => routeDistance(earth, jupiter, b) > routeDistance(earth, jupiter, a) ? b : a, ); for (const ship of content.shipModels) { const reaches = checkRoute(maxedStats(ship.id), earth, jupiter, farthest).ok; expect(reaches, ship.id).toBe(ship.id === "bulk-hauler"); } }); it("gives the Courier 450 % range per tanks level", () => { expect(upgradePercentPerLevel(content.upgrade("fuel-tanks")!, "courier")).toBe(450); }); });