// report reflects model/report/Report data object
include "common.fbs";

namespace report;

table RouteEntry {
  key:uint64;
  value:string;
}

table TechEntry {
  key:string;
  value:float32;
}

table Route {
  planet:uint64;
  route:[RouteEntry];
}

table Player {
  name:string;
  drive:float32;
  weapons:float32;
  shields:float32;
  cargo:float32;
  population:float32;
  industry:float32;
  planets:uint16;
  relation:string;
  votes:float32;
  extinct:bool;
}

table Science {
  name:string;
  drive:float32;
  weapons:float32;
  shields:float32;
  cargo:float32;
}

table OtherScience {
  race:string;
  name:string;
  drive:float32;
  weapons:float32;
  shields:float32;
  cargo:float32;
}

table ShipClass {
  name:string;
  drive:float32;
  armament:uint64;
  weapons:float32;
  shields:float32;
  cargo:float32;
  mass:float32;
}

table OthersShipClass {
  race:string;
  name:string;
  drive:float32;
  armament:uint64;
  weapons:float32;
  shields:float32;
  cargo:float32;
  mass:float32;
}

table ShipProduction {
  planet:uint64;
  class:string;
  cost:float32;
  prod_used:float32;
  percent:float32;
  free:float32;
}

table IncomingGroup {
  origin:uint64;
  destination:uint64;
  distance:float32;
  speed:float32;
  mass:float32;
}

table Bombing {
  number:uint64;
  planet:string;
  owner:string;
  attacker:string;
  production:string;
  industry:float32;
  population:float32;
  colonists:float32;
  capital:float32;
  material:float32;
  attack_power:float32;
  wiped:bool;
}

table UnidentifiedPlanet {
  x:float32;
  y:float32;
  number:uint64;
}

table UninhabitedPlanet {
  x:float32;
  y:float32;
  number:uint64;
  size:float32;
  name:string;
  resources:float32;
  capital:float32;
  material:float32;
}

table LocalPlanet {
  x:float32;
  y:float32;
  number:uint64;
  size:float32;
  name:string;
  resources:float32;
  capital:float32;
  material:float32;
  industry:float32;
  population:float32;
  colonists:float32;
  production:string;
  free_industry:float32;
}

table OtherPlanet {
  owner:string;
  x:float32;
  y:float32;
  number:uint64;
  size:float32;
  name:string;
  resources:float32;
  capital:float32;
  material:float32;
  industry:float32;
  population:float32;
  colonists:float32;
  production:string;
  free_industry:float32;
}

table UnidentifiedGroup {
  x:float32;
  y:float32;
}

table OtherGroup {
  number:uint64;
  class:string;
  tech:[TechEntry];
  cargo:string;
  load:float32;
  destination:uint64;
  origin:uint64 = null;
  range:float32 = null;
  speed:float32;
  mass:float32;
}

table LocalGroup {
  number:uint64;
  class:string;
  tech:[TechEntry];
  cargo:string;
  load:float32;
  destination:uint64;
  origin:uint64 = null;
  range:float32 = null;
  speed:float32;
  mass:float32;
  id:common.UUID (required);
  state:string;
  fleet:string;
}

table LocalFleet {
  name:string;
  groups:uint64;
  destination:uint64;
  origin:uint64 = null;
  range:float32 = null;
  speed:float32;
  state:string;
}

// BattleSummary identifies one battle the report recipient
// participated in or could see on a planet. `planet` lets the map
// place a battle marker without fetching the full BattleReport;
// `shots` lets the marker scale its stroke with the protocol length
// (1 shot → thinnest cross, 100+ shots → maximum cross thickness).
table BattleSummary {
  id:common.UUID (required);
  planet:uint64;
  shots:uint64;
}

table Report {
  version:uint64;
  turn:uint64;
  width:uint32;
  height:uint32;
  planet_count:uint32;
  race:string;
  votes:float32;
  vote_for:string;
  player:[Player];
  local_science:[Science];
  other_science:[OtherScience];
  local_ship_class:[ShipClass];
  other_ship_class:[OthersShipClass];
  battle:[BattleSummary];
  bombing:[Bombing];
  incoming_group:[IncomingGroup];
  local_planet:[LocalPlanet];
  ship_production:[ShipProduction];
  route:[Route];
  other_planet:[OtherPlanet];
  uninhabited_planet:[UninhabitedPlanet];
  unidentified_planet:[UnidentifiedPlanet];
  local_fleet:[LocalFleet];
  local_group:[LocalGroup];
  other_group:[OtherGroup];
  unidentified_group:[UnidentifiedGroup];
}

// GameReportRequest is the signed-gRPC request payload for
// `MessageTypeUserGamesReport`. Gateway transcodes this into the
// engine's `?player=&turn=` query string after resolving the caller's
// race name from the runtime player mapping; only `game_id` and `turn`
// travel on the wire.
table GameReportRequest {
  game_id:common.UUID (required);
  turn:uint32;
}

root_type Report;
