64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
// Aircraft catalog — in-code constants for now (no DB table yet). One type is
|
||
// enough for the MVP; add more entries to PLANE_TYPES as they are designed.
|
||
|
||
export interface PlaneType {
|
||
id: string;
|
||
name: string;
|
||
// Fuel capacity, liters.
|
||
maxFuel: number;
|
||
// Fuel burn per km of flight, liters/km (cruise).
|
||
burnPerKm: number;
|
||
// Cruise speed, km/h — used by the sim tick to advance planes along routes.
|
||
speedKmh: number;
|
||
// Market price in € (v0.8.0): buying costs `price`, selling pays out
|
||
// SELL_FRACTION × price.
|
||
price: number;
|
||
}
|
||
|
||
export const PLANE_TYPES: Record<string, PlaneType> = {
|
||
atr72: {
|
||
id: 'atr72',
|
||
name: 'ATR 72-600',
|
||
maxFuel: 6300,
|
||
burnPerKm: 1.75, // ~900 kg/h at 510 km/h cruise (Jet-A1 ≈ 0.8 kg/L)
|
||
speedKmh: 510,
|
||
// €200k — with the starting cash of €20k and typical hop rewards (~€1–3k),
|
||
// a second ATR takes sustained play to afford, as intended for the MVP sink.
|
||
price: 200_000,
|
||
},
|
||
};
|
||
|
||
// The plane the player starts with.
|
||
export const STARTER_MODEL = 'atr72';
|
||
|
||
// Jet-A1 fuel price in €/liter (v0.8.0): refueling cost = (maxFuel − fuel) × this.
|
||
export const FUEL_PRICE_PER_L = 0.8;
|
||
|
||
// Fraction of the catalog price paid out when selling a plane (v0.8.0).
|
||
export const SELL_FRACTION = 0.5;
|
||
|
||
// Snapshot shape of one catalog entry in GET /api/state (v0.10.0): `model` is the
|
||
// id used by buy/dispatch, `label` the display name — clients compute all market
|
||
// previews (buy price, sell payout, refuel cost) from these + the economy constants.
|
||
export interface CatalogEntry {
|
||
model: string;
|
||
label: string;
|
||
price: number;
|
||
maxFuel: number;
|
||
burnPerKm: number;
|
||
speedKmh: number;
|
||
}
|
||
|
||
// The catalog as a flat array, one entry per plane type — the single source of
|
||
// truth for both the sim (PLANE_TYPES) and the client snapshot.
|
||
export function catalogEntries(): CatalogEntry[] {
|
||
return Object.values(PLANE_TYPES).map((t) => ({
|
||
model: t.id,
|
||
label: t.name,
|
||
price: t.price,
|
||
maxFuel: t.maxFuel,
|
||
burnPerKm: t.burnPerKm,
|
||
speedKmh: t.speedKmh,
|
||
}));
|
||
}
|