{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://remake.soh.tools/schema/glitch.schema.json",
  "title": "Glitch",
  "description": "One published glitch in the Ocarina of Time remake (Switch 2). Lives at content/glitches/<slug>.yml and is only written by an approved pull request.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "slug",
    "name",
    "summary",
    "category",
    "status",
    "rta_viable",
    "age",
    "versions",
    "patched_in",
    "discovered_by",
    "first_seen",
    "evidence",
    "updated"
  ],
  "properties": {
    "id": { "$ref": "common.schema.json#/$defs/glitchId" },
    "slug": { "$ref": "common.schema.json#/$defs/slug" },
    "name": { "type": "string", "minLength": 1, "maxLength": 120 },
    "aliases": {
      "type": "array",
      "items": { "type": "string", "minLength": 1, "maxLength": 120 },
      "uniqueItems": true
    },
    "summary": { "type": "string", "minLength": 1, "maxLength": 500 },
    "category": { "$ref": "common.schema.json#/$defs/category" },
    "status": { "$ref": "common.schema.json#/$defs/status" },
    "rta_viable": {
      "description": "Usable in real-time speedruns.",
      "type": "boolean"
    },
    "age": { "$ref": "common.schema.json#/$defs/age" },
    "requirements": {
      "description": "Item or state slugs, e.g. deku-stick. Use the remake's own names; don't assume classic-game names carry over.",
      "type": "array",
      "items": { "$ref": "common.schema.json#/$defs/slug" },
      "uniqueItems": true
    },
    "setup": {
      "description": "Written setup steps (Markdown). Escaped when rendered.",
      "type": "string",
      "minLength": 1
    },
    "versions": {
      "description": "Every game version this glitch was tested on. Each version must exist in content/versions.yml.",
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["version", "works", "tested"],
        "properties": {
          "version": { "$ref": "common.schema.json#/$defs/version" },
          "works": { "type": "boolean" },
          "tested": { "$ref": "common.schema.json#/$defs/date" }
        }
      }
    },
    "patched_in": {
      "description": "First version where it no longer works; null when not patched.",
      "$ref": "common.schema.json#/$defs/versionOrNull"
    },
    "discovered_by": {
      "type": "array",
      "items": { "$ref": "common.schema.json#/$defs/person" }
    },
    "first_seen": {
      "description": "Earliest evidence timestamp.",
      "$ref": "common.schema.json#/$defs/utcDateTime"
    },
    "evidence": {
      "type": "array",
      "items": { "$ref": "common.schema.json#/$defs/evidenceId" },
      "minItems": 1,
      "uniqueItems": true
    },
    "related": {
      "type": "array",
      "items": { "$ref": "common.schema.json#/$defs/glitchId" },
      "uniqueItems": true
    },
    "updated": { "$ref": "common.schema.json#/$defs/date" }
  },
  "allOf": [
    {
      "description": "A patched glitch must say which version patched it.",
      "if": {
        "properties": { "status": { "const": "patched" } },
        "required": ["status"]
      },
      "then": {
        "properties": { "patched_in": { "type": "string" } }
      }
    }
  ]
}
