deadhead-space-freight-tycoon/packages/sim/src/fuel.ts

30 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { GameConfig, Location, ShipModel } from "@deadhead/content";
/**
* The distance pay and fuel are charged on (decision 0.5.84): the route distance
* scaled down for long legs, `reference × (distance / reference)^exponent`.
* A leg of the reference length (Earth–Moon) is unchanged; an exponent of 1
* makes it the plain distance. Range, travel time and XP use the plain distance.
*/
export function economicDistance(distanceMillionKm: number, config: GameConfig): number {
const { referenceMillionKm, exponent } = config.economicDistance;
return referenceMillionKm * (distanceMillionKm / referenceMillionKm) ** exponent;
}
/**
* Fuel cost in credits: economic distance × the ship's cost per million km ×
* the origin's launch multiplier.
*/
export function fuelCost(
ship: ShipModel,
origin: Location,
distanceMillionKm: number,
config: GameConfig,
): number {
return (
economicDistance(distanceMillionKm, config) *
ship.fuelCostPerMillionKm *
origin.launchCostMultiplier
);
}