<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="state" type="statetype"/>

    <xs:simpleType name="statetypetype" final="restriction">
        <xs:restriction base="xs:string">
            <xs:enumeration value="before_battle"/>
            <xs:enumeration value="during_battle"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="propertiestype">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" name="item">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="key" type="xs:string"  />
                        <xs:element name="value" type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="combatmodetype" final="restriction">
        <xs:restriction base="xs:string">
            <xs:enumeration value="COMBAT_MODE_DEFEND"/>
            <xs:enumeration value="COMBAT_MODE_HIDE"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="positiontype">
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9]+,[0-9]+"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="directiontype">
        <xs:restriction base="xs:float"/>
    </xs:simpleType>

    <xs:complexType name="statetype">
        <xs:sequence>
            <xs:element name="map" type="maptype" maxOccurs="1"/>
            <xs:element name="subjects" type="subjectstype"/>
        </xs:sequence>
        <xs:attribute name="type" type="statetypetype" use="required"/>
    </xs:complexType>

    <xs:complexType name="subjectstype">
        <xs:sequence>
            <xs:element name="subject" type="subjecttype" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="subjecttype">
        <xs:sequence>
            <xs:element name="type" type="xs:string" minOccurs="1" />
            <xs:element name="position" type="positiontype" minOccurs="1"/>
            <xs:element name="direction" type="directiontype" minOccurs="1"/>
            <xs:element name="combat_mode" type="combatmodetype" minOccurs="1"/>
            <xs:element name="properties" type="propertiestype" minOccurs="1"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="maptype">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

</xs:schema>