{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://blackautumn.divinevtt.com/modding/schemas/mod.schema.json",
  "title": "mod.json",
  "description": "What a Black Autumn: 1438 mod is and what it has. Every key but id may be left out.",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "this schema's address, for an editor"
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9_-]+$",
      "description": "lower-case letters, digits, - and _; the folder's name when left out"
    },
    "title": {
      "type": "string"
    },
    "version": {
      "type": "string"
    },
    "author": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "format": {
      "type": "integer",
      "description": "the modding format it was made with",
      "minimum": 1,
      "maximum": 4
    },
    "weapons": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/weapon"
      }
    },
    "armour": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/piece"
      }
    },
    "armor": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/piece"
      }
    },
    "bodies": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/body"
      }
    },
    "sets": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/set"
      }
    },
    "sieges": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/siege"
      }
    },
    "commands": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/command"
      }
    },
    "patches": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "$ref": "https://blackautumn.divinevtt.com/modding/schemas/patches.schema.json#/$defs/entry"
          },
          {
            "type": "string",
            "pattern": "\\.json$",
            "description": "a file of the mod holding entries"
          }
        ]
      }
    },
    "graphs": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "\\.graph\\.json$",
        "description": "a graph file of the mod"
      }
    },
    "maps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/map"
      }
    },
    "brains": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "\\.json$",
        "description": "a brain file of the mod"
      }
    },
    "texts": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        ],
        "description": "a file of words, or a list"
      },
      "description": "words by language code: cs, sk, en..."
    },
    "requires": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/need"
      }
    },
    "workshop": {
      "type": [
        "integer",
        "string"
      ],
      "description": "its Workshop item, written when first published"
    },
    "template": {
      "type": "string"
    }
  },
  "$defs": {
    "weapon": {
      "type": "object",
      "description": "a new weapon made from one of ours (name and base), or one of ours changed in place (changes)",
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_]+$",
          "description": "its own name; in the game <mod id>.<name>"
        },
        "changes": {
          "type": "string",
          "description": "one of ours changed in place, by its name"
        },
        "base": {
          "type": "string",
          "description": "the weapon of ours it is made from"
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "picture": {
          "type": "string",
          "description": "a PNG of the mod, blade up, 40 pixels to a unit"
        },
        "grip": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "the pixel the main hand holds, [x, y] from the top left"
        },
        "offGrip": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "the pixel the other hand holds"
        },
        "edge": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "minItems": 2,
            "maxItems": 2,
            "description": "a pixel"
          },
          "minItems": 2,
          "maxItems": 2,
          "description": "where the blow lands: two pixels"
        },
        "edgeWidth": {
          "type": "number",
          "description": "the blow's width in pixels",
          "minimum": 0.0
        },
        "icon": {
          "type": "string",
          "description": "its icon, a PNG of the mod"
        },
        "weapon": {
          "type": "object",
          "description": "numbers written over the base's, by the names its components keep them under"
        },
        "hit": {
          "type": "object",
          "description": "numbers written over the base's, by the names its components keep them under"
        },
        "pickup": {
          "type": "object",
          "description": "numbers written over the base's, by the names its components keep them under"
        },
        "points": {
          "type": "integer",
          "description": "what it costs of a loadout's 100 points",
          "minimum": 0,
          "maximum": 100
        },
        "shot": {
          "type": "object",
          "description": "a gun's rounds: colour, core, length, width, glow, light, lightStrength, picture, burst, sparks, scorch, debris, smoke, cases"
        },
        "heat": {
          "type": "object",
          "description": "a gun that heats: perShot, cooling, coolDelay, unlockAt, ventBoost, reach, light"
        },
        "grenade": {
          "type": "object",
          "description": "goes off once thrown: fuse, reach, damage, smoke, colour, blink, sound"
        },
        "shield": {
          "type": "object",
          "description": "throws an energy shield up where it comes to rest: radius, lasts, strength, after, colour"
        },
        "magazine": {
          "type": "string",
          "description": "a gun's magazine as a picture of the mod"
        },
        "sounds": {
          "type": "object",
          "description": "sound slots, each a file of the mod or a list of them, one played at random",
          "additionalProperties": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ],
            "description": "a .wav, .ogg or .mp3 file of the mod, or a list"
          }
        }
      },
      "anyOf": [
        {
          "required": [
            "name",
            "base"
          ]
        },
        {
          "required": [
            "changes"
          ]
        }
      ]
    },
    "piece": {
      "type": "object",
      "description": "a new piece of armour or clothing made from one of ours (name and base), or one of ours changed (changes)",
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_]+$",
          "description": "its own name; in the game <mod id>.<name>"
        },
        "changes": {
          "type": "string"
        },
        "base": {
          "type": "string",
          "description": "the piece of ours it is made from"
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "picture": {
          "type": "string",
          "description": "its sheet, laid out exactly like the base's, 24 pixels to a unit"
        },
        "pictures": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "the base's other sheets by their object's name"
        },
        "icon": {
          "type": "string"
        },
        "piece": {
          "type": "object",
          "description": "numbers over the base's ArmorPiece: head, torso, arms, legs, cut, stab, blunt, arrow, weight..."
        },
        "points": {
          "type": "integer",
          "description": "what it costs of a loadout's 100 points",
          "minimum": 0,
          "maximum": 100
        }
      },
      "anyOf": [
        {
          "required": [
            "name",
            "base"
          ]
        },
        {
          "required": [
            "changes"
          ]
        }
      ]
    },
    "body": {
      "type": "object",
      "description": "a whole body drawn instead of ours",
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_]+$",
          "description": "its own name"
        },
        "title": {
          "type": "string"
        },
        "picture": {
          "type": "string",
          "description": "a sheet laid out like ManBody (144 x 112), or 2, 3 or 4 times that size"
        },
        "bald": {
          "type": "boolean"
        },
        "blood": {
          "type": "boolean"
        },
        "size": {
          "type": "number",
          "description": "how big it stands beside a person of ours (1)",
          "minimum": 0.6,
          "maximum": 1.5
        },
        "paints": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "colour": {
                "type": "string",
                "pattern": "^#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$",
                "description": "#rrggbb"
              }
            }
          }
        },
        "voice": {
          "type": "object",
          "properties": {
            "spot": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "hurt": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "death": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "antenna": {
          "type": "object",
          "description": "a stalk standing on the head or the body",
          "properties": {
            "picture": {
              "type": "string"
            },
            "on": {
              "enum": [
                "head",
                "body"
              ]
            },
            "root": {
              "type": "object",
              "properties": {
                "down": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "minItems": 2,
                  "maxItems": 2,
                  "description": null
                },
                "up": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "minItems": 2,
                  "maxItems": 2,
                  "description": null
                },
                "left": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "minItems": 2,
                  "maxItems": 2,
                  "description": null
                },
                "right": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "minItems": 2,
                  "maxItems": 2,
                  "description": null
                }
              },
              "required": [
                "down",
                "up",
                "left",
                "right"
              ]
            },
            "behind": {
              "type": "array",
              "items": {
                "enum": [
                  "down",
                  "up",
                  "left",
                  "right"
                ]
              }
            }
          },
          "required": [
            "picture",
            "root"
          ]
        }
      },
      "required": [
        "name",
        "picture"
      ]
    },
    "set": {
      "type": "object",
      "description": "a whole outfit worn together",
      "properties": {
        "title": {
          "type": "string"
        },
        "pieces": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "pieces"
      ]
    },
    "command": {
      "type": "object",
      "description": "a dev chat command dressing a player",
      "properties": {
        "word": {
          "type": "string",
          "pattern": "^\\S+$",
          "description": "one word"
        },
        "what": {
          "type": "string"
        },
        "worn": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "weapon": {
          "type": "string"
        },
        "crystal": {
          "type": "string"
        }
      },
      "required": [
        "word"
      ]
    },
    "siege": {
      "type": "object",
      "description": "a game mode made from the Šášov siege",
      "properties": {
        "name": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "note": {
          "type": "string"
        },
        "startLine": {
          "type": "integer",
          "minimum": 0
        },
        "map": {
          "type": "string"
        },
        "attackers": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "name, body, paint, weapon, offHand, clothes, carried, from, share, company, shape (Mob, Line, Loose), skill, notice"
          }
        },
        "ranks": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "kills, title, weapon, carried, pieces"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "map": {
      "type": "object",
      "description": "an arena map of the mod's own, over one of ours",
      "properties": {
        "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"
        },
        "file": {
          "type": "string",
          "pattern": "\\.map\\.json$",
          "description": "a map file of the mod"
        },
        "places": {
          "type": "array",
          "items": {
            "$ref": "https://blackautumn.divinevtt.com/modding/schemas/patches.schema.json#/$defs/entry"
          }
        },
        "patches": {
          "type": "array",
          "items": {
            "$ref": "https://blackautumn.divinevtt.com/modding/schemas/patches.schema.json#/$defs/entry"
          }
        }
      },
      "required": [
        "name",
        "scene"
      ]
    },
    "need": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-z0-9_-]+$",
          "description": "a mod's id"
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[a-z0-9_-]+$",
              "description": "a mod's id"
            },
            "version": {
              "type": "string",
              "description": "the least version it takes"
            },
            "workshop": {
              "type": [
                "integer",
                "string"
              ]
            }
          },
          "required": [
            "id"
          ]
        }
      ]
    }
  }
}
