#pragma once
#include "lephisto.h"
#include "outfit.h"
#include "opengl.h"

// Target gfx dimensions.
#define SHIP_TARGET_W 128
#define SHIP_TARGET_H 96

typedef enum ShipClass_ {
  SHIP_CLASS_NULL       = 0,
  SHIP_CLASS_CIV_LIGHT  = 1,
  SHIP_CLASS_CIV_MEDIUM = 2,
  SHIP_CLASS_CIV_HEAVY  = 3,
  SHIP_CLASS_MIL_LIGHT  = 4,
  SHIP_CLASS_MIL_MEDIUM = 5,
  SHIP_CLASS_MIL_HEAVY  = 6,
  SHIP_CLASS_ROB_LIGHT  = 7,
  SHIP_CLASS_ROB_MEDIUM = 8,
  SHIP_CLASS_ROB_HEAVY  = 9,
  SHIP_CLASS_HYB_LIGHT  = 10,
  SHIP_CLASS_HYB_MEDIUM = 11,
  SHIP_CLASS_HYB_HEAVY  = 12
} ShipClass;

// Small wrapper for the outfits.
typedef struct ShipOutfit_ {
  struct ShipOutfit_* next; // Linked list.
  Outfit* data; // Data itself.
  int quantity;
} ShipOutfit;


// Ship structure.
typedef struct Ship_ {
  char* name; // Ship name.
  ShipClass class; // Ship class.

  // Store stuff.
  int price;      // Price!
  int tech;
  char* fabricator;  // Manufacturer.
  char* description; // Sales pitch.

  // Movement.
  double thrust, turn, speed;

  // Graphics.
  glTexture* gfx_space, *gfx_target;

  // GUI interface.
  char* gui;

  // Sound.
  ALuint sound;

  // Characteristics.
  int crew;
  int mass;

  // Health.
  double armour, armour_regen;
  double shield, shield_regen;
  double energy, energy_regen;

  // Capacity.
  int cap_cargo, cap_weapon;

  // Outfits
  ShipOutfit* outfit;
} Ship;

// Get.
Ship* ship_get(const char* name);
char** ship_getTech(int* n, const int* tech, const int techmax);
char* ship_class(Ship* p);

// Load/quit.
int ships_load(void);
void ships_free(void);

// Toolkit.
void ship_view(char* shipname);