<?xml version="1.0" encoding="utf-8"?>
<!--

    Copyright (c) 2001-2020 Mathew A. Nelson and Robocode contributors
    All rights reserved. This program and the accompanying materials
    are made available under the terms of the Eclipse Public License v1.0
    which accompanies this distribution, and is available at
    https://robocode.sourceforge.io/license/epl-v10.html

-->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:complexType name="Score">
    <xs:attribute name="name" type="xs:string" use="optional"/>
    <xs:attribute name="t" type="xs:double" use="optional"/>
    <xs:attribute name="tss" type="xs:double" use="optional"/>
    <xs:attribute name="tls" type="xs:double" use="optional"/>
    <xs:attribute name="tbd" type="xs:double" use="optional"/>
    <xs:attribute name="tbk" type="xs:double" use="optional"/>
    <xs:attribute name="trd" type="xs:double" use="optional"/>
    <xs:attribute name="trk" type="xs:double" use="optional"/>
    <xs:attribute name="t1" type="xs:int" use="optional"/>
    <xs:attribute name="t2" type="xs:int" use="optional"/>
    <xs:attribute name="t3" type="xs:int" use="optional"/>
    <xs:attribute name="c" type="xs:double" use="required"/>
    <xs:attribute name="ss" type="xs:double" use="required"/>
    <xs:attribute name="bd" type="xs:double" use="required"/>
    <xs:attribute name="bk" type="xs:double" use="required"/>
    <xs:attribute name="rd" type="xs:double" use="required"/>
    <xs:attribute name="rk" type="xs:double" use="required"/>
    <xs:attribute name="ver" type="xs:int" use="optional"/>
  </xs:complexType>

  <xs:simpleType name="RobotState">
    <xs:restriction base = "xs:string">
      <xs:enumeration value = "ACTIVE"/>
      <xs:enumeration value = "HIT_WALL"/>
      <xs:enumeration value = "HIT_ROBOT"/>
      <xs:enumeration value = "DEAD"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="Robot">
    <xs:sequence>
      <xs:element name="sc" type="Score"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:unsignedByte" use="required" />
    <xs:attribute name="ver" type="xs:int" use="optional"/>
    <xs:attribute name="name" type="xs:string" use="optional"/>
    <xs:attribute name="sName" type="xs:string" use="optional"/>
    <xs:attribute name="vsName" type="xs:string" use="optional"/>
    <xs:attribute name="teamName" type="xs:string" use="optional"/>
    <xs:attribute name="s" type="RobotState" use="optional" default="ACTIVE"/>
    <xs:attribute name="e" type="xs:double" use="required"/>
    <xs:attribute name="v" type="xs:double" use="required"/>
    <xs:attribute name="b" type="xs:double" use="required"/>
    <xs:attribute name="g" type="xs:double" use="required"/>
    <xs:attribute name="r" type="xs:double" use="required"/>
    <xs:attribute name="x" type="xs:double" use="required"/>
    <xs:attribute name="y" type="xs:double" use="required"/>
    <xs:attribute name="out" type="xs:string" use="optional"/>
    <xs:attribute name="h" type="xs:double" use="optional"/>
    <xs:attribute name="bodyColor" type="xs:string" use="optional"/>
    <xs:attribute name="gunColor" type="xs:string" use="optional"/>
    <xs:attribute name="radarColor" type="xs:string" use="optional"/>
    

  </xs:complexType>

  <xs:simpleType name="BulletState">
    <xs:restriction base = "xs:string">
      <xs:enumeration value = "FIRED"/>
      <xs:enumeration value = "MOVING"/>
      <xs:enumeration value = "HIT_VICTIM"/>
      <xs:enumeration value = "HIT_BULLET"/>
      <xs:enumeration value = "HIT_WALL"/>
      <xs:enumeration value = "EXPLODED"/>
      <xs:enumeration value = "INACTIVE"/>
    </xs:restriction>
  </xs:simpleType>


  <xs:complexType name="Bullet">
    <xs:attribute name="id" type="xs:string" use="required" />
    <xs:attribute name="ver" type="xs:int" use="optional"/>
    <xs:attribute name="s" type="BulletState" use="optional" default="MOVING"/>
    <xs:attribute name="p" type="xs:double" use="optional"/>
    <xs:attribute name="c" type="xs:int" use="optional"/>
    <xs:attribute name="x" type="xs:double" use="required"/>
    <xs:attribute name="y" type="xs:double" use="required"/>
    <xs:attribute name="frame" type="xs:int" use="optional" default="0"/>
    <xs:attribute name="isExplosion" type="xs:boolean" use="optional"/>
    <xs:attribute name="explosion" type="xs:int" use="optional"/>
    <xs:attribute name="h" type="xs:double" use="optional"/>
    <xs:attribute name="o" type="xs:int" use="optional" />
    <xs:attribute name="v" type="xs:int" use="optional" default="-1"/>
  </xs:complexType>

  <xs:complexType name="Turn">
    <xs:sequence>
      <xs:element name="rs">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="r" type="Robot">
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="bs">
        <xs:complexType>
          <xs:sequence minOccurs="0">
            <xs:element maxOccurs="unbounded" name="b" type="Bullet"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="ro" type="xs:int" use="required"/>
    <xs:attribute name="tu" type="xs:int" use="required"/>
    <xs:attribute name="ver" type="xs:int" use="optional"/>
  </xs:complexType>

  <xs:complexType name="Rules">
    <xs:attribute name="battlefieldWidth" type="xs:int"/>
    <xs:attribute name="battlefieldHeight" type="xs:int"/>
    <xs:attribute name="numRounds" type="xs:int"/>
    <xs:attribute name="gunCoolingRate" type="xs:double"/>
    <xs:attribute name="inactivityTime" type="xs:int"/>
    <xs:attribute name="ver" type="xs:int"/>
  </xs:complexType>

  <xs:complexType name="Result">
    <xs:attribute name="teamLeaderName" type="xs:string" use="required"/>
    <xs:attribute name="rank" type="xs:int" use="required"/>
    <xs:attribute name="score" type="xs:double" use="required"/>
    <xs:attribute name="survival" type="xs:double" use="required"/>
    <xs:attribute name="lastSurvivorBonus" type="xs:double" use="required"/>
    <xs:attribute name="bulletDamage" type="xs:double" use="required"/>
    <xs:attribute name="bulletDamageBonus" type="xs:double" use="required"/>
    <xs:attribute name="ramDamage" type="xs:double" use="required"/>
    <xs:attribute name="ramDamageBonus" type="xs:double" use="required"/>
    <xs:attribute name="firsts" type="xs:int" use="required"/>
    <xs:attribute name="seconds" type="xs:int" use="required"/>
    <xs:attribute name="thirds" type="xs:int" use="required"/>
    <xs:attribute name="ver" type="xs:int" use="optional"/>
  </xs:complexType>

  <xs:complexType name="RecordInfo">
    <xs:sequence>

      <xs:element name="rules" type="Rules">
      </xs:element>
      <xs:element name="rounds">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="turns" maxOccurs="unbounded">
              <xs:complexType>
                <xs:attribute name="value" type="xs:int" use="required"/>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="results">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="result" type="Result">
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="robotCount" type="xs:int" use="required"/>
    <xs:attribute name="roundsCount" type="xs:int" use="required"/>
    <xs:attribute name="ver" type="xs:int" use="optional"/>
  </xs:complexType>

  <xs:complexType name="Record">
    <xs:sequence>
      <xs:element name="recordInfo" type="RecordInfo"/>
      <xs:element name="turns">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="t" type="Turn" maxOccurs="unbounded"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="record" type="Record"/>

</xs:schema>