deadhead-space-freight-tycoon/packages/sim/test/courier-mars.test.ts

32 lines
1.3 KiB
TypeScript

import { content, upgradePercentPerLevel, type ShipModel } from "@deadhead/content";
import { describe, expect, it } from "vitest";
import { checkRoute } from "../src/index";
const courier = content.shipModel("courier")!;
const tanks = content.upgrade("fuel-tanks")!;
const earth = content.location("earth")!;
const moon = content.location("moon")!;
const mars = content.location("mars")!;
const now = Date.parse("2100-01-01T00:00:00Z");
/** 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),
});
// Decision 0.5.68 as amended by CR-015: a plain yes or no on the fixed map.
describe("Courier to Mars (decision 0.5.68)", () => {
it("reaches Mars from Earth with maxed fuel tanks", () => {
expect(checkRoute(withTanks(3), earth, mars, now)).toEqual({ ok: true });
});
it("can't reach Mars from Earth or the Moon with fuel tanks at level 2 or less", () => {
for (const level of [0, 1, 2]) {
expect(checkRoute(withTanks(level), earth, mars, now).ok, `level ${level}`).toBe(false);
expect(checkRoute(withTanks(level), moon, mars, now).ok, `level ${level}`).toBe(false);
}
});
});