35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import { content, upgradePercentPerLevel, type ShipModel } from "@deadhead/content";
|
|
import { describe, expect, it } from "vitest";
|
|
import { checkRoute, realToGame } from "../src/index";
|
|
|
|
const courier = content.shipModel("courier")!;
|
|
const tanks = content.upgrade("fuel-tanks")!;
|
|
const earth = content.location("earth")!;
|
|
const mars = content.location("mars")!;
|
|
|
|
/** A Courier with fuel tanks at `level` (decision 0.5.63: linear % of base range). */
|
|
const withTanks = (level: number): ShipModel => ({
|
|
...courier,
|
|
fuelRangeMillionKm:
|
|
courier.fuelRangeMillionKm * (1 + (upgradePercentPerLevel(tanks, "courier") * level) / 100),
|
|
});
|
|
|
|
/** Monthly samples over the first two game years. */
|
|
const MONTH = 30.44 * 24 * 3_600_000;
|
|
const start = realToGame(Date.parse(content.config.epoch.realStart), content.config);
|
|
const samples = Array.from({ length: 25 }, (_, i) => start + i * MONTH);
|
|
const inRange = (ship: ShipModel) =>
|
|
samples.map((t) => checkRoute(ship, earth, mars, t)).map((r) => r.ok);
|
|
|
|
describe("Courier to Mars (decision 0.5.68)", () => {
|
|
it("reaches Mars with maxed fuel tanks near closest approach, but not at its farthest", () => {
|
|
const reach = inRange(withTanks(3));
|
|
expect(reach.some(Boolean)).toBe(true);
|
|
expect(reach.some((ok) => !ok)).toBe(true);
|
|
});
|
|
|
|
it("never reaches Mars with fuel tanks at level 2 or less", () => {
|
|
for (const level of [0, 1, 2]) expect(inRange(withTanks(level)).some(Boolean)).toBe(false);
|
|
});
|
|
});
|