deadhead-space-freight-tycoon/packages/schema/test/save-fixture.ts

224 lines
5.6 KiB
TypeScript

import type { Contract, SaveDocument } from "../src/index";
const T = Date.parse("2100-01-01T00:00:00Z");
/** A contract as the sim builds it. */
export const sampleContract: Contract = {
id: "earth:1:0",
originId: "earth",
destinationId: "moon",
cargoTypeId: "standard",
goodId: "consumer-goods",
shipper: "Pacific Orbital Logistics",
priority: false,
deliveryWindowGameHours: null,
tier: 0,
massTonnes: 12,
payout: 1500,
requiredSkill: null,
requiredLongHaulLevel: 0,
offeredAt: T,
expiresAt: T + 600_000,
firstContact: false,
};
/**
* A save with every collection and every optional field filled: a mid-game
* company after the deal, with an upgraded ship in the shop, a resting pilot,
* one flight under way and one resolved and unseen.
*/
export function fullSave(): SaveDocument {
const record = (id: string, arrivalAt: number) => ({
id,
shipId: "s1",
pilotId: "avatar",
contract: sampleContract,
originId: "earth",
destinationId: "moon",
tutorial: false,
departureAt: T,
arrivalAt,
distanceMillionKm: 0.38,
fuelBurnedFu: 7.6,
fuelCost: 160,
expectedPayout: 1500,
seed: 42,
});
return {
saveVersion: 7,
saveId: "save-1",
lastTimeSeen: T + 3_600_000,
player: {
worldSeed: 0xdeadbeef,
tutorialActive: false,
loanerLocationId: null,
tutorialRunsCompleted: 4,
dealAccepted: true,
createdAt: T,
welcomeSeen: true,
},
company: {
id: "co1",
name: "Deadhead Freight",
credits: 12_345,
loanBalance: 60_000,
dispatchOffice: false,
npcSpendingFloor: 500,
},
ships: [
{
id: "s1",
modelId: "courier",
name: "Dusty Mule",
status: "in-flight",
locationId: null,
upgrades: { engines: 2, "fuel-tanks": 1 },
inShopUntil: null,
shopUpgradeId: null,
shopLevel: null,
fromDeal: true,
createdAt: T,
lastArrivalAt: T + 200_000,
fuelFu: 52.4,
fuelAvgPrice: 15.2,
refuelPolicy: "auto",
},
{
id: "s2",
modelId: "clipper",
name: "Swift Heron",
status: "idle",
locationId: "earth",
upgrades: {},
inShopUntil: T + 7_200_000,
shopUpgradeId: "cargo-bay",
shopLevel: 1,
fromDeal: true,
createdAt: T,
lastArrivalAt: T,
fuelFu: 1170,
fuelAvgPrice: 16,
refuelPolicy: "manual",
},
],
pilots: [
{
id: "avatar",
name: "Captain",
isAvatar: true,
isVeteran: false,
xp: 120,
skills: { "long-haul": 1 },
skillPointsSpent: 1,
assignedShipId: "s1",
locationId: null,
status: "in-flight",
dutyHours: 4.5,
restEndsAt: null,
createdAt: T,
mode: "manual",
nextDecisionAt: null,
emptyPeriods: 0,
orders: {
destinationIds: null,
cargoClassIds: ["standard", "heavy", "high-value", "dangerous"],
takePriority: true,
minProfit: 0,
homeLocationId: "earth",
},
},
{
id: "veteran",
name: "Rosa Kell",
isAvatar: false,
isVeteran: true,
xp: 250,
skills: { "expensive-cargo": 1 },
skillPointsSpent: 1,
assignedShipId: "s2",
locationId: null,
status: "idle",
dutyHours: 0,
restEndsAt: T + 3_000_000,
createdAt: T,
mode: "manual",
nextDecisionAt: null,
emptyPeriods: 0,
orders: {
destinationIds: null,
cargoClassIds: ["standard", "heavy", "high-value", "dangerous"],
takePriority: true,
minProfit: 0,
homeLocationId: "earth",
},
},
],
bays: [{ id: "b1", locationId: "earth", createdAt: T }],
discoveredLocations: [
{ locationId: "earth", discoveredAt: T },
{ locationId: "moon", discoveredAt: T },
],
contractBoards: [
{
id: "board-1",
kind: "location",
locationId: "earth",
periodIndex: 1,
tutorialRun: 0,
contracts: [sampleContract],
fleet: [{ modelId: "courier", skills: {} }],
createdAt: T,
},
],
dispatches: [
{
id: "d1",
shipId: "s1",
pilotId: "avatar",
tutorial: false,
independent: false,
record: record("d1", T + 9_000_000),
arrivalAt: T + 9_000_000,
status: "in-flight",
resolution: null,
resolvedAt: null,
acknowledgedAt: null,
},
{
id: "d0",
shipId: "s1",
pilotId: "avatar",
tutorial: false,
independent: false,
record: record("d0", T + 200_000),
arrivalAt: T + 200_000,
status: "resolved",
resolution: {
credits: 1000,
topUp: {
locationId: "moon",
boughtFu: 7.6,
price: 11,
cost: 84,
tank: { fuelFu: 40, avgPrice: 11 },
},
pilotPay: 0,
loanRepayment: 340,
pilotXp: 10,
shipLocationId: "moon",
discoversDestination: false,
pilotDutyHours: 2.4,
pilotRestEndsAt: null,
},
resolvedAt: T + 200_000,
acknowledgedAt: null,
},
],
acceptedContracts: [
{ contractId: sampleContract.id, periodIndex: 1, dispatchId: "d1", acceptedAt: T },
],
claimedGoals: [{ goalId: "first-own-delivery", claimedAt: T + 300_000 }],
stats: { contractDeliveries: 1, priorityDeliveries: 0 },
};
}