import { newGuid } from '../utils';

export const AircraftType = {
  PLANE: 'Plane',
  VTOL: 'VTOL',
} as const;

export type AircraftTypeValue = (typeof AircraftType)[keyof typeof AircraftType];

export class Aircraft {
  name: string;
  fuelperkm: number;
  maxfuel: number;
  type: AircraftTypeValue;
  downang: number | undefined;
  upang: number | undefined;
  id: string;

  constructor(
    name: string,
    fuelperkm: number,
    maxfuel: number,
    type: AircraftTypeValue,
    downang?: number,
    upang?: number,
    id: string = newGuid(),
  ) {
    this.name = name;
    this.fuelperkm = fuelperkm;
    this.maxfuel = maxfuel;
    this.type = type;

    if (type === AircraftType.PLANE) {
      this.downang = downang;
      this.upang = upang;
    } else {
      this.downang = undefined;
      this.upang = undefined;
    }

    this.id = id;
  }
}
