{
  "$id": "https://dnd-gm.local/schemas/map-contract.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "contractVersion",
    "mapId",
    "startNodeId",
    "nodes",
    "edges"
  ],
  "properties": {
    "contractVersion": {
      "const": "1.0.0"
    },
    "mapId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "startNodeId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "nodes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "regionId",
          "visibility",
          "tags"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "regionId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "visibility": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "const": "public"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "const": "party"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "branchId"
                ],
                "properties": {
                  "kind": {
                    "const": "branch"
                  },
                  "branchId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "playerIds"
                ],
                "properties": {
                  "kind": {
                    "const": "players"
                  },
                  "playerIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "uniqueItems": true
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "const": "gm"
                  }
                }
              }
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "uniqueItems": true
          }
        }
      }
    },
    "edges": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "from",
          "to",
          "bidirectional",
          "travelCost",
          "blocksLineOfSight"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "from": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "to": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "bidirectional": {
            "type": "boolean"
          },
          "travelCost": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          },
          "requiredItemId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "blocksLineOfSight": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
