{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ResourceBundle",
  "type": "object",
  "properties": {
    "characters": {
      "type": "array",
      "default": [],
      "items": {
        "$ref": "#/$defs/CharacterCard"
      }
    },
    "display_name": {
      "type": "string"
    },
    "entry_character": {
      "type": "string"
    },
    "entry_persona": {
      "type": "string"
    },
    "entry_plot_module": {
      "type": [
        "string",
        "null"
      ]
    },
    "id": {
      "type": "string"
    },
    "item_specs": {
      "type": "array",
      "default": [],
      "items": {
        "$ref": "#/$defs/ItemSpec"
      }
    },
    "personas": {
      "type": "array",
      "default": [],
      "items": {
        "$ref": "#/$defs/Persona"
      }
    },
    "plot_modules": {
      "type": "array",
      "default": [],
      "items": {
        "$ref": "#/$defs/PlotModule"
      }
    },
    "revision": {
      "type": "string"
    },
    "schema_version": {
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "world_books": {
      "type": "array",
      "default": [],
      "items": {
        "$ref": "#/$defs/WorldBook"
      }
    }
  },
  "required": [
    "id",
    "schema_version",
    "revision",
    "display_name",
    "entry_character",
    "entry_persona"
  ],
  "$defs": {
    "AcquisitionMode": {
      "type": "string",
      "enum": [
        "initial",
        "found",
        "given",
        "borrowed",
        "stolen",
        "returned"
      ]
    },
    "CharacterCard": {
      "type": "object",
      "properties": {
        "boundaries": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "default_expression": {
          "type": "string"
        },
        "header": {
          "$ref": "#/$defs/ResourceHeader"
        },
        "identity": {
          "type": "string"
        },
        "initial_relationship": {
          "$ref": "#/$defs/RelationshipAxes"
        },
        "judgment_rules": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/CharacterJudgmentRule"
          }
        },
        "name": {
          "type": "string"
        },
        "personality": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "skills": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/SkillValue"
          }
        },
        "style": {
          "$ref": "#/$defs/CharacterStyle"
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "header",
        "name",
        "identity",
        "personality",
        "values",
        "boundaries",
        "style",
        "initial_relationship",
        "default_expression"
      ]
    },
    "CharacterJudgmentRule": {
      "type": "object",
      "properties": {
        "meaning": {
          "type": "string"
        },
        "relationship_effects": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/RelationshipAdjustment"
          }
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "tags",
        "meaning"
      ]
    },
    "CharacterStyle": {
      "type": "object",
      "properties": {
        "forbidden_player_assumptions": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "mannerisms": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "speech": {
          "type": "string"
        }
      },
      "required": [
        "speech"
      ]
    },
    "CheckDifficulty": {
      "type": "string",
      "enum": [
        "regular",
        "hard",
        "extreme"
      ]
    },
    "CheckRecord": {
      "type": "object",
      "properties": {
        "action_id": {
          "type": "string"
        },
        "actor": {
          "type": "string"
        },
        "bonus_dice": {
          "type": "integer",
          "format": "int8",
          "maximum": 127,
          "minimum": -128
        },
        "difficulty": {
          "$ref": "#/$defs/CheckDifficulty"
        },
        "id": {
          "type": "string"
        },
        "node_id": {
          "type": "string"
        },
        "pushed_from": {
          "type": [
            "string",
            "null"
          ]
        },
        "result": {
          "$ref": "#/$defs/CheckResult"
        },
        "roll": {
          "type": "integer",
          "format": "uint8",
          "maximum": 255,
          "minimum": 0
        },
        "skill": {
          "type": "string"
        },
        "target": {
          "type": "integer",
          "format": "uint8",
          "maximum": 255,
          "minimum": 0
        }
      },
      "required": [
        "id",
        "action_id",
        "actor",
        "skill",
        "target",
        "difficulty",
        "bonus_dice",
        "roll",
        "result",
        "node_id"
      ]
    },
    "CheckResult": {
      "type": "string",
      "enum": [
        "critical_success",
        "extreme_success",
        "hard_success",
        "success",
        "failure",
        "fumble"
      ]
    },
    "ItemAcquisition": {
      "type": "object",
      "properties": {
        "at_node": {
          "type": "string"
        },
        "from": {
          "type": [
            "string",
            "null"
          ]
        },
        "mode": {
          "$ref": "#/$defs/AcquisitionMode"
        }
      },
      "required": [
        "mode",
        "at_node"
      ]
    },
    "ItemInstance": {
      "type": "object",
      "properties": {
        "acquisition": {
          "$ref": "#/$defs/ItemAcquisition"
        },
        "condition": {
          "type": "string"
        },
        "holder": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "owner": {
          "type": "string"
        },
        "placement": {
          "$ref": "#/$defs/ItemPlacement"
        },
        "quantity": {
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        },
        "spec_ref": {
          "type": "string"
        },
        "state_tags": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "id",
        "spec_ref",
        "owner",
        "holder",
        "placement",
        "quantity",
        "condition",
        "acquisition"
      ]
    },
    "ItemMechanics": {
      "type": "object",
      "properties": {
        "check_modifier": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int8",
          "maximum": 127,
          "minimum": -128
        },
        "grants_tags": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "usable": {
          "type": "boolean"
        }
      },
      "required": [
        "usable"
      ]
    },
    "ItemPlacement": {
      "type": "string",
      "enum": [
        "bag",
        "worn",
        "hand",
        "scene",
        "hidden"
      ]
    },
    "ItemSpec": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string"
        },
        "header": {
          "$ref": "#/$defs/ResourceHeader"
        },
        "hidden_facts": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "lore_refs": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "mechanics": {
          "$ref": "#/$defs/ItemMechanics"
        },
        "name": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "header",
        "name",
        "description",
        "tags",
        "mechanics"
      ]
    },
    "KnowledgeCertainty": {
      "type": "string",
      "enum": [
        "suspected",
        "reported",
        "confirmed"
      ]
    },
    "KnowledgeRecord": {
      "type": "object",
      "properties": {
        "certainty": {
          "$ref": "#/$defs/KnowledgeCertainty"
        },
        "fact": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "last_verified_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "learned_at": {
          "type": "string"
        },
        "observer": {
          "type": "string"
        },
        "source": {
          "type": "string"
        },
        "subject": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "observer",
        "fact",
        "certainty",
        "source",
        "learned_at"
      ]
    },
    "Persona": {
      "type": "object",
      "properties": {
        "header": {
          "$ref": "#/$defs/ResourceHeader"
        },
        "identity": {
          "type": "string"
        },
        "initial_items": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "name": {
          "type": "string"
        },
        "skills": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/SkillValue"
          }
        },
        "traits": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "header",
        "name",
        "identity"
      ]
    },
    "PlotEvent": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "outcomes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PlotOutcome"
          }
        },
        "pressures": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/PlotPressure"
          }
        },
        "required_flags": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "situation": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "title": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "title",
        "tags",
        "situation",
        "outcomes"
      ]
    },
    "PlotModule": {
      "type": "object",
      "properties": {
        "events": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PlotEvent"
          }
        },
        "header": {
          "$ref": "#/$defs/ResourceHeader"
        },
        "name": {
          "type": "string"
        },
        "opening_event": {
          "type": "string"
        }
      },
      "required": [
        "header",
        "name",
        "opening_event",
        "events"
      ]
    },
    "PlotOutcome": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string"
        },
        "effects": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/StateOp"
          }
        },
        "id": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "description"
      ]
    },
    "PlotPressure": {
      "type": "object",
      "properties": {
        "clock_delta": {
          "type": [
            "integer",
            "null"
          ],
          "format": "uint16",
          "maximum": 65535,
          "minimum": 0
        },
        "clock_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "description": {
          "type": "string"
        },
        "id": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "description"
      ]
    },
    "Promise": {
      "type": "object",
      "properties": {
        "accepted_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "content": {
          "type": "string"
        },
        "created_at": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "promisee": {
          "type": "string"
        },
        "promiser": {
          "type": "string"
        },
        "resolved_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "$ref": "#/$defs/PromiseStatus"
        },
        "weight": {
          "$ref": "#/$defs/PromiseWeight"
        }
      },
      "required": [
        "id",
        "promiser",
        "promisee",
        "content",
        "status",
        "weight",
        "created_at"
      ]
    },
    "PromiseStatus": {
      "type": "string",
      "enum": [
        "proposed",
        "accepted",
        "fulfilled",
        "broken",
        "released",
        "impossible"
      ]
    },
    "PromiseWeight": {
      "type": "string",
      "enum": [
        "minor",
        "major"
      ]
    },
    "RelationshipAdjustment": {
      "type": "object",
      "properties": {
        "cause": {
          "type": "string"
        },
        "delta": {
          "type": "integer",
          "format": "int16",
          "maximum": 32767,
          "minimum": -32768
        },
        "dimension": {
          "$ref": "#/$defs/RelationshipDimension"
        },
        "judgment_rule": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "dimension",
        "delta",
        "cause"
      ]
    },
    "RelationshipAxes": {
      "type": "object",
      "properties": {
        "affinity": {
          "type": "integer",
          "format": "int16",
          "maximum": 32767,
          "minimum": -32768
        },
        "attachment": {
          "type": "integer",
          "format": "int16",
          "maximum": 32767,
          "minimum": -32768
        },
        "hope": {
          "type": "integer",
          "format": "int16",
          "maximum": 32767,
          "minimum": -32768
        },
        "intimacy": {
          "type": "integer",
          "format": "int16",
          "maximum": 32767,
          "minimum": -32768
        },
        "respect": {
          "type": "integer",
          "format": "int16",
          "maximum": 32767,
          "minimum": -32768
        },
        "trust": {
          "type": "integer",
          "format": "int16",
          "maximum": 32767,
          "minimum": -32768
        }
      },
      "required": [
        "affinity",
        "trust",
        "hope",
        "respect",
        "intimacy",
        "attachment"
      ]
    },
    "RelationshipDimension": {
      "type": "string",
      "enum": [
        "affinity",
        "trust",
        "hope",
        "respect",
        "intimacy",
        "attachment"
      ]
    },
    "ResourceHeader": {
      "type": "object",
      "properties": {
        "content_hash": {
          "type": "string"
        },
        "dependencies": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/ResourceRef"
          }
        },
        "id": {
          "type": "string"
        },
        "kind": {
          "$ref": "#/$defs/ResourceKind"
        },
        "revision": {
          "type": "string"
        },
        "schema_version": {
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        }
      },
      "required": [
        "id",
        "kind",
        "schema_version",
        "revision",
        "content_hash"
      ]
    },
    "ResourceKind": {
      "type": "string",
      "enum": [
        "character",
        "world_book",
        "persona",
        "plot_module",
        "item_spec"
      ]
    },
    "ResourceRef": {
      "type": "object",
      "properties": {
        "content_hash": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "kind": {
          "$ref": "#/$defs/ResourceKind"
        },
        "revision": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "kind",
        "revision",
        "content_hash"
      ]
    },
    "SkillValue": {
      "type": "object",
      "properties": {
        "skill": {
          "type": "string"
        },
        "value": {
          "type": "integer",
          "format": "uint8",
          "maximum": 255,
          "minimum": 0
        }
      },
      "required": [
        "skill",
        "value"
      ]
    },
    "StateOp": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "key": {
              "type": "string"
            },
            "op": {
              "type": "string",
              "const": "set_world_flag"
            },
            "value": {
              "type": "boolean"
            }
          },
          "required": [
            "op",
            "key",
            "value"
          ]
        },
        {
          "type": "object",
          "properties": {
            "adjustment": {
              "$ref": "#/$defs/RelationshipAdjustment"
            },
            "from": {
              "type": "string"
            },
            "op": {
              "type": "string",
              "const": "adjust_relationship"
            },
            "to": {
              "type": "string"
            }
          },
          "required": [
            "op",
            "from",
            "to",
            "adjustment"
          ]
        },
        {
          "type": "object",
          "properties": {
            "op": {
              "type": "string",
              "const": "create_promise"
            },
            "promise": {
              "$ref": "#/$defs/Promise"
            }
          },
          "required": [
            "op",
            "promise"
          ]
        },
        {
          "type": "object",
          "properties": {
            "op": {
              "type": "string",
              "const": "update_promise"
            },
            "promise_id": {
              "type": "string"
            },
            "resolved_at": {
              "type": [
                "string",
                "null"
              ]
            },
            "status": {
              "$ref": "#/$defs/PromiseStatus"
            }
          },
          "required": [
            "op",
            "promise_id",
            "status"
          ]
        },
        {
          "type": "object",
          "properties": {
            "op": {
              "type": "string",
              "const": "add_knowledge"
            },
            "record": {
              "$ref": "#/$defs/KnowledgeRecord"
            }
          },
          "required": [
            "op",
            "record"
          ]
        },
        {
          "type": "object",
          "properties": {
            "item": {
              "$ref": "#/$defs/ItemInstance"
            },
            "op": {
              "type": "string",
              "const": "add_item"
            }
          },
          "required": [
            "op",
            "item"
          ]
        },
        {
          "type": "object",
          "properties": {
            "from": {
              "type": "string"
            },
            "item_id": {
              "type": "string"
            },
            "mode": {
              "$ref": "#/$defs/AcquisitionMode"
            },
            "op": {
              "type": "string",
              "const": "transfer_item"
            },
            "placement": {
              "$ref": "#/$defs/ItemPlacement"
            },
            "to": {
              "type": "string"
            }
          },
          "required": [
            "op",
            "item_id",
            "from",
            "to",
            "placement",
            "mode"
          ]
        },
        {
          "type": "object",
          "properties": {
            "check": {
              "$ref": "#/$defs/CheckRecord"
            },
            "op": {
              "type": "string",
              "const": "record_check"
            }
          },
          "required": [
            "op",
            "check"
          ]
        },
        {
          "type": "object",
          "properties": {
            "clock_id": {
              "type": "string"
            },
            "delta": {
              "type": "integer",
              "format": "uint16",
              "maximum": 65535,
              "minimum": 0
            },
            "op": {
              "type": "string",
              "const": "advance_clock"
            }
          },
          "required": [
            "op",
            "clock_id",
            "delta"
          ]
        }
      ]
    },
    "WorldBook": {
      "type": "object",
      "properties": {
        "entries": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WorldBookEntry"
          }
        },
        "header": {
          "$ref": "#/$defs/ResourceHeader"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "header",
        "name",
        "entries"
      ]
    },
    "WorldBookEntry": {
      "type": "object",
      "properties": {
        "content": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "keywords": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "required_flags": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "tags": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        },
        "title": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "title",
        "content"
      ]
    }
  }
}
