{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://blackautumn.divinevtt.com/modding/schemas/map.schema.json",
  "title": "map file",
  "description": "A map of the map editor: the map of ours it is built over, its ground, its pieces and things.",
  "$defs": {
    "set": {
      "type": "object",
      "description": "a setting as a patch writes it",
      "properties": {
        "path": {
          "type": "string",
          "description": "Component.field"
        },
        "value": {
          "type": "string",
          "description": "the value as JSON text"
        }
      },
      "required": [
        "path"
      ]
    },
    "knot": {
      "type": "object",
      "description": "a knot of a line",
      "properties": {
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "inX": {
          "type": "number"
        },
        "inY": {
          "type": "number"
        },
        "outX": {
          "type": "number"
        },
        "outY": {
          "type": "number"
        },
        "mode": {
          "enum": [
            "",
            "auto",
            "line",
            "mirror",
            "free"
          ],
          "description": "auto (empty), line (a corner), mirror, free"
        }
      },
      "required": [
        "x",
        "y"
      ]
    },
    "data": {
      "type": "object",
      "description": "numbers along a line at knot places",
      "properties": {
        "key": {
          "type": "string"
        },
        "at": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "values": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      },
      "required": [
        "key"
      ]
    },
    "line": {
      "type": "object",
      "description": "a line of knots",
      "properties": {
        "closed": {
          "type": "boolean"
        },
        "knots": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/knot"
          }
        },
        "data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/data"
          }
        }
      }
    },
    "piece": {
      "type": "object",
      "description": "a piece: one of the game's own spline pieces",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9_]+$",
          "description": "its own id"
        },
        "kind": {
          "enum": [
            "building/brick-house",
            "wall/castle-area",
            "wall/castle-wall",
            "building/log-cabin",
            "building/plank-shed",
            "wall/roof-wall",
            "building/round-tower-roofed",
            "building/round-tower",
            "building/stone-gate-tower",
            "building/stone-house",
            "building/stone-keep",
            "building/stone-pile",
            "building/stone-tower",
            "building/stone-wall",
            "building/timber-house",
            "wall/wall-gate",
            "wall/wall-shed",
            "wall/wall-stairs",
            "building/adit-drainage",
            "building/adit-old",
            "building/adit-working",
            "building/burnt-barn",
            "building/burnt-farmhouse",
            "building/charcoal-burners-hut",
            "building/farm-barn",
            "building/farm-cart-shed",
            "building/farm-cow-shed",
            "building/farmhouse",
            "building/field-hut",
            "building/ford-smithy",
            "building/hay-barrack",
            "building/hay-shelter",
            "building/hermit-cell",
            "building/hip-roofed-barn",
            "building/hip-roofed-cottage",
            "building/hitching-rail",
            "building/lime-kiln",
            "building/mine-shaft-house",
            "building/open-shed-on-posts",
            "building/pinga-collar",
            "building/pinga-line",
            "building/pinga-post",
            "building/pinga",
            "building/roadside-tavern",
            "building/shepherds-hut",
            "building/smallholding-barn",
            "building/smallholding-cottage",
            "building/smallholding-pigsty",
            "building/stamp-mill",
            "building/tavern-stable",
            "building/toll-bar",
            "building/toll-house",
            "building/watermill-overshot",
            "building/watermill-undershot",
            "building/watermill-with-house",
            "building/wayside-chapel",
            "building/woodcutters-lean-to",
            "fence/bar-log-drop",
            "fence/bar-log",
            "fence/fence-gate",
            "fence/palisade-gate",
            "fence/palisade-loophole",
            "fence/palisade-walkway",
            "fence/palisade-window",
            "fence/palisade",
            "fence/post-and-rail-fence",
            "fence/posts",
            "fence/walkway-ladder",
            "fence/walkway-stairs",
            "field/barley-field",
            "field/flax-field",
            "field/ploughed-field",
            "field/sown-field",
            "field/stubble-field",
            "field/wheat-field",
            "wood/autumn-wood",
            "wood/dead-wood",
            "wood/fir-forest",
            "wood/forest",
            "wood/mixed-forest",
            "wood/open-woodland",
            "wood/riverside-wood",
            "wood/thick-forest",
            "grass/bramble-thicket",
            "grass/bush-thicket",
            "grass/flower-meadow",
            "grass/grass-area",
            "grass/lawn-area",
            "grass/long-grass-area",
            "grass/no-bushes-area",
            "grass/no-grass-area",
            "grass/overgrown-area",
            "grass/scattered-bushes",
            "ground/dirt-area",
            "ground/ditch",
            "ground/farmyard",
            "ground/forest-floor",
            "ground/gravel-area",
            "ground/hill",
            "ground/loose-stone",
            "ground/midden",
            "ground/mud-area",
            "ground/overgrowth",
            "ground/well-mud",
            "ground/wood-yard",
            "road/dirt-track",
            "road/gravel-road",
            "road/mud-track",
            "road/stone-road",
            "road/worn-path",
            "rock/cliff-face",
            "rock/cliff-height",
            "rock/earth-mesa",
            "rock/granite-tor",
            "rock/hillside-ledge",
            "rock/limestone-crag",
            "rock/low-shelf",
            "rock/rock-face",
            "rock/rock-outcrop",
            "rock/rock-tor",
            "rock/sandstone-rocks",
            "rock/cave-crag-deep",
            "rock/cave-crag-shelter",
            "rock/cave-deep",
            "rock/cave-overhang",
            "rock/cave-shelter",
            "tree/any-tree",
            "tree/autumn-tree",
            "tree/bare-tree",
            "tree/fir",
            "tree/olive-tree",
            "tree/sparse-tree",
            "tree/tree",
            "water/ford",
            "water/marsh",
            "water/pond",
            "water/river",
            "water/stepping-stones",
            "water/stone-bridge",
            "water/wooden-bridge",
            "wildlife/crows-on-roofs",
            "wildlife/crows",
            "wildlife/fly-swarm",
            "wildlife/larks",
            "wildlife/sparrows",
            "place/private",
            "place/map-area"
          ],
          "description": "what it is"
        },
        "label": {
          "type": "string"
        },
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "turn": {
          "type": "number"
        },
        "scale": {
          "type": "number"
        },
        "off": {
          "type": "boolean"
        },
        "lines": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/line"
          }
        },
        "set": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/set"
          }
        }
      },
      "required": [
        "id",
        "kind"
      ]
    },
    "thing": {
      "type": "object",
      "description": "a thing made where the map is played",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9_]+$",
          "description": "its own id"
        },
        "thing": {
          "type": "string",
          "pattern": "^(prop|thing|item|beast|person)/.+",
          "description": "prop/<kit name>, thing/<catalog>, item/<id>, beast/<kind>, person/<kind>"
        },
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "turn": {
          "type": "number"
        },
        "count": {
          "type": "integer",
          "minimum": 1
        },
        "off": {
          "type": "boolean"
        },
        "set": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/set"
          }
        }
      },
      "required": [
        "id",
        "thing"
      ]
    }
  },
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "this schema's address, for an editor"
    },
    "map": {
      "type": "integer",
      "description": "the map file format",
      "minimum": 1,
      "maximum": 1
    },
    "name": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "note": {
      "type": "string"
    },
    "scene": {
      "enum": [
        "ring",
        "sasov",
        "ford",
        "farm",
        "quarry",
        "yard"
      ],
      "description": "the map of ours it is built over"
    },
    "bare": {
      "type": "boolean",
      "description": "our map's own world taken away"
    },
    "halfW": {
      "type": "number"
    },
    "halfH": {
      "type": "number"
    },
    "x": {
      "type": "number"
    },
    "y": {
      "type": "number"
    },
    "pieces": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/piece"
      }
    },
    "things": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/thing"
      }
    }
  },
  "additionalProperties": false
}
