import { Entity, EntityKind } from './Entity';
import { HumanReadableString, Slug, ItemForm } from './primitive';

/**
 * A building that consumes power
 */
export interface PoweredBuilding extends Building {
  /**
   * The amount of power consumed by this building.
   */
  powerConsumption: BuildingPowerConsumption;
}

/**
 * Any entity which can be built by the player (factory buildings, foundations,
 * conveyers, etc).
 */
export interface Building extends Entity {
  kind: EntityKind.Building;

  /**
   * A detailed description of the building.
   */
  description: HumanReadableString;

  // Common collections of metadata.

  /**
   * Whether the building can be overclocked.
   */
  overclockable?: true;

  /**
   * The amount of power consumed by this building.
   */
  powerConsumption?: BuildingPowerConsumption;

  /**
   * The amount of power generated by this building.
   */
  powerProduction?: BuildingPowerProduction;

  // Specific building type details.

  /**
   * Details about how a building can extract raw resources.
   */
  extraction?: BuildingResourceExtraction;

  /**
   * Dimensions of the storage provided by a building.
   */
  storage?: BuildingStorageDetails;

  /**
   * Details about the conveyance of the building.
   */
  conveyor?: BuildingConveyorDetails;
}

// Common collections of metadata.

/**
 * Measure of power consumption for a building.
 */
export interface BuildingPowerConsumption {
  amount: number;
  exponent: number;
}

/**
 * Measure of power production for a building.
 */
export interface BuildingPowerProduction {
  amount: number;
  exponent: number;
  fuels?: Slug[];
  fuelForm?: ItemForm;
}

// Specific building type details.

/**
 * The rate at which a building can extract resources.
 */
export interface BuildingResourceExtraction {
  cycleTime: number;
  itemsPerCycle: number;
  resources: Slug[];
}

/**
 * Dimensions of a storage container.
 */
export interface BuildingStorageDetails {
  x: number;
  y: number;
}

/**
 * Details about a conveyor.
 */
export interface BuildingConveyorDetails {
  speed: number;
}
