// Pure ship-system model: the known system types, base values and the action cost model. // No DB imports — both lib/game/ship.ts (server) and the frontend import from here so the // UI's affordability/cap logic can never drift from what the API enforces. export interface ShipTypeDef { type: string builtAtStart: boolean // part of the starting ship? (otherwise unbuilt until BUILD) } // The known system types — display order. Reuses the placeholder SHIP SYSTEMS tab card names // for continuity, plus HULL so the vessel-metrics hull bar can be driven by a real level. export const SHIP_TYPES: ShipTypeDef[] = [ { type: 'HULL', builtAtStart: true }, { type: 'REACTOR', builtAtStart: true }, { type: 'LIFE SUPPORT', builtAtStart: true }, { type: 'NAV COMPUTER', builtAtStart: true }, { type: 'COMMS ARRAY', builtAtStart: true }, { type: 'WEAPONS', builtAtStart: false }, ] export const BASE_LEVEL = 1 // what a system starts at when built (starting ship or BUILD) export const BASE_CAPACITY = 2 export const MAX_LEVEL = 5 // UPGRADE cap export const MAX_CAPACITY = 10 // EXPAND cap // Display-only cap for the VESSEL METRICS crew roster bar (no gameplay effect yet). export const CREW_CAPACITY = 6 // Cost model — all costs are in inventory items, consumed from the oldest cargo row of the // required kind first (see spendItems in lib/game/ship.ts): // UPGRADE {systemId} — `level` units of any resource (scales with current level) // EXPAND {systemId} — `capacity` units of any resource (scales with current capacity) // BUILD {type} — a flat amount of parts (parts are rarer than resources, so builds // are the bigger investment) export function upgradeCost(level: number): number { return level } export function expandCost(capacity: number): number { return capacity } export const BUILD_PART_COST = 3 // Total qty of one kind across the cargo hold — used for affordability checks. export function totalQty(items: { kind: string; qty: number }[], kind: 'resource' | 'part'): number { return items.filter((i) => i.kind === kind).reduce((sum, i) => sum + i.qty, 0) }