import { content } from "@deadhead/content"; import { describe, expect, it } from "vitest"; import { boardPeriodIndex, generateTutorialBoard, loanerModel, type TutorialBoardInput, } from "../src/index"; import { buildContract } from "../src/board"; const periodIndex = boardPeriodIndex(Date.parse("2100-01-01T00:00:00Z"), content.config); const atEarth: TutorialBoardInput = { loanerLocationId: "earth", periodIndex, worldSeed: 99 }; const atMoon: TutorialBoardInput = { ...atEarth, loanerLocationId: "moon" }; describe("tutorial board", () => { it("offers only Earth→Moon when the loaner is at Earth", () => { for (const c of generateTutorialBoard(atEarth, content)) { expect([c.originId, c.destinationId]).toEqual(["earth", "moon"]); } }); it("offers only Moon→Earth when the loaner is at the Moon", () => { for (const c of generateTutorialBoard(atMoon, content)) { expect([c.originId, c.destinationId]).toEqual(["moon", "earth"]); } }); it("has the configured size, Standard cargo only, sized to fit the loaner", () => { const board = generateTutorialBoard(atEarth, content); expect(board).toHaveLength(content.config.tutorialBoardSize); for (const c of board) { expect(c.cargoTypeId).toBe("standard"); expect(c.tier).toBe(0); expect(c.requiredSkill).toBeNull(); expect(c.requiredLongHaulLevel).toBe(0); expect(c.firstContact).toBe(false); expect(c.massTonnes).toBeLessThanOrEqual(loanerModel(content).cargoCapacityTonnes); } }); it("pays exactly the tutorial share of the equivalent normal payout", () => { for (const input of [atEarth, atMoon]) { for (const c of generateTutorialBoard(input, content)) { const normal = buildContract( { id: c.id, origin: content.location(c.originId)!, destination: content.location(c.destinationId)!, cargoType: content.cargoType("standard")!, tier: 0, massTonnes: c.massTonnes, firstContact: false, periodIndex, }, content, ); expect(c.payout).toBe(Math.round(normal.payout * content.config.tutorialPayoutShare)); expect(c.payout).toBeLessThan(normal.payout); } } }); it("is deterministic", () => { expect(generateTutorialBoard(atEarth, content)).toEqual( generateTutorialBoard(atEarth, content), ); }); });