import { content } from "@deadhead/content"; import { describe, expect, it } from "vitest"; import { buildContract } from "../src/board"; import { createDispatchRecord, type Contract } from "../src/index"; /** Fuel enough for any leg in these tests (decision 0.5.94), bought at 10 cr/fu. */ const PLENTY = { fuelFu: 10_000, avgPrice: 10 }; const earth = content.location("earth")!; const ceres = content.location("ceres-station")!; const good = content.goods.find( (g) => g.producedAt.includes("earth") && g.demandedAt.includes("ceres-station"), )!; const DAY = 24 * 3_600_000; /** The same Earth → Ceres job, offered in a given board period. */ function offered(periodIndex: number): Contract { return buildContract( { id: `c${periodIndex}`, origin: earth, destination: ceres, good, tier: 0, massTonnes: 30, firstContact: false, periodIndex, shipper: "Test Freight", priority: false, deliveryWindowGameHours: null, }, content, ); } function flown(contract: Contract, now: number) { const ship = { id: "s1", modelId: "freighter", locationId: "earth", inFlight: false, tank: PLENTY, }; const pilot = { id: "p1", isAvatar: false, assignedShipId: "s1", inFlight: false, skills: {}, restEndsAt: null, }; return createDispatchRecord( { id: "d1", ship, pilot, contract, tutorial: false, now, worldSeed: 1 }, content, ); } // Step 15.2 (decision 0.5.93): nothing about a route depends on when. describe("static routes", () => { it("pays the same for a route whenever it is offered", () => { const payouts = [0, 1, 1_000, 52_000].map((period) => offered(period).payout); expect(new Set(payouts).size).toBe(1); }); it("takes the same time, distance and fuel whenever it is dispatched", () => { const contract = offered(0); const trips = [0, 37 * DAY, 400 * DAY, 3_000 * DAY].map((t) => { const record = flown(contract, Date.parse("2100-01-01T00:00:00Z") + t); return { duration: record.arrivalAt - record.departureAt, distance: record.distanceMillionKm, fuel: record.fuelCost, }; }); for (const trip of trips) expect(trip).toEqual(trips[0]); }); });