{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "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"
  ],
  "$defs": {
    "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"
      ]
    },
    "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"
      ]
    }
  }
}
