import { Deserialize } from "../util/deserialize.model";
import { ServerSublevelModel } from "./serverSublevel.model";
import { IslandInstanceModel } from "./island-instance.model";
import { DiscoveryZoneModel } from "./discovery-zone.model";

export class ServerModel implements Deserialize {
  // General Settings
  name: string;
  gridX: number;
  gridY: number;
  isHomeServer: boolean;
  utcOffset: number;

  // Connection Settings
  ip: string;
  port: number;
  gamePort: number;
  seamlessDataPort: number;

  // Gameplay Settings
  floorZDist: number;
  transitionMinZ: number;
  serverIslandPointsMultiplier: number;

  // Colour & Style Settings
  waterColorR: number;
  waterColorG: number;
  waterColorB: number;
  skyStyleIndex: number;

  // Override Settings
  OceanDinoDepthEntriesOverride: string;
  oceanFloatsamCratesOverride: string;
  treasureMapLootTablesOverride: string;
  OverrideShooterGameModeDefaultGameIni: object;

  //Dont render if default/empty
  GlobalBiomeSeamlessServerGridPreOffsetValues: string;
  GlobalBiomeSeamlessServerGridPreOffsetValuesOceanWater: string;
  oceanEpicSpawnEntriesOverrideTemplateName: string;
  NPCShipSpawnEntriesOverrideTemplateName: string;
  regionOverrides: string;


  lastImageOverride: string;

  extraSublevels: string[];
  totalExtraSublevels: string[];
  islandInstances: IslandInstanceModel[];
  discoZones: DiscoveryZoneModel[];
  spawnRegions;

  // Dont render if default/empty
  serverTemplateName: string;

  sublevels: ServerSublevelModel[];

  // Irrelevant, used internally by Grapeshot
  //MachineIdTag: string;
  // Probably also irrelevant
  //AdditionalCmdLineParams: string;

  // Used by ServerGridEditor
  //islandLocked: boolean;
  //discoLocked: boolean;
  //pathsLocked: boolean;

  // Editing time for ServerGridEditor
  //lastModified: string;


  deserialize(input: any): this {
    Object.assign(this, input);
    this.sublevels = this.sublevels.map(i => new ServerSublevelModel().deserialize(i));
    this.islandInstances = this.islandInstances.map(i => new IslandInstanceModel().deserialize(i));
    this.discoZones = this.discoZones.map(i => new DiscoveryZoneModel().deserialize(i));
    return this;
  }
}