21 lines
882 B
TypeScript
21 lines
882 B
TypeScript
import type { GameConfig, ShipModel } from "@deadhead/content";
|
|
|
|
/**
|
|
* Trip duration in game hours: cruise time, the ship's fixed takeoff/landing
|
|
* overhead, and loading/unloading time for the cargo (decision 0.5.31). Pass
|
|
* the distance at departure; it is not recalculated mid-flight. Repositions
|
|
* carry zero mass.
|
|
*/
|
|
export function travelTimeGameHours(
|
|
/** Effective stats carry the ship's own handling time (decision 0.5.63); a bare model uses the game-wide base. */
|
|
ship: ShipModel & { handlingGameHoursPerTonne?: number },
|
|
distanceMillionKm: number,
|
|
massTonnes: number,
|
|
config: GameConfig,
|
|
): number {
|
|
const cruiseHours = (distanceMillionKm * 1e6) / ship.cruiseSpeedKmPerGameHour;
|
|
const handlingHours =
|
|
massTonnes * (ship.handlingGameHoursPerTonne ?? config.handlingGameHoursPerTonne);
|
|
return cruiseHours + ship.overheadGameHours + handlingHours;
|
|
}
|