{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "TurnResult",
  "type": "object",
  "properties": {
    "committedNodeId": {
      "type": "string"
    },
    "playerView": {
      "$ref": "#/$defs/PlayerView"
    }
  },
  "required": [
    "committedNodeId",
    "playerView"
  ],
  "$defs": {
    "ActionSuggestion": {
      "type": "object",
      "properties": {
        "draft": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "label": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "label",
        "draft"
      ]
    },
    "BeatKind": {
      "type": "string",
      "enum": [
        "narration",
        "dialogue",
        "action",
        "system"
      ]
    },
    "HistoryNodeView": {
      "type": "object",
      "properties": {
        "branchId": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "isCurrent": {
          "type": "boolean"
        },
        "label": {
          "type": "string"
        },
        "parentId": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "branchId",
        "label",
        "isCurrent"
      ]
    },
    "ItemPlacement": {
      "type": "string",
      "enum": [
        "bag",
        "worn",
        "hand",
        "scene",
        "hidden"
      ]
    },
    "KnowledgeCertainty": {
      "type": "string",
      "enum": [
        "suspected",
        "reported",
        "confirmed"
      ]
    },
    "PlayerItemView": {
      "type": "object",
      "properties": {
        "condition": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "instanceId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "placement": {
          "$ref": "#/$defs/ItemPlacement"
        },
        "quantity": {
          "type": "integer",
          "format": "uint32",
          "minimum": 0
        }
      },
      "required": [
        "instanceId",
        "name",
        "description",
        "quantity",
        "placement",
        "condition"
      ]
    },
    "PlayerKnowledgeView": {
      "type": "object",
      "properties": {
        "certainty": {
          "$ref": "#/$defs/KnowledgeCertainty"
        },
        "id": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "title": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "title",
        "summary",
        "certainty"
      ]
    },
    "PlayerPromiseView": {
      "type": "object",
      "properties": {
        "content": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "status": {
          "$ref": "#/$defs/PromiseStatus"
        },
        "weight": {
          "$ref": "#/$defs/PromiseWeight"
        }
      },
      "required": [
        "id",
        "content",
        "status",
        "weight"
      ]
    },
    "PlayerView": {
      "type": "object",
      "properties": {
        "beats": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PresentationBeat"
          }
        },
        "branchId": {
          "type": "string"
        },
        "canContinue": {
          "type": "boolean"
        },
        "characterExpression": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "characterName": {
          "type": "string"
        },
        "characterPose": {
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "history": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/HistoryNodeView"
          }
        },
        "inventory": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/PlayerItemView"
          }
        },
        "knowledge": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/PlayerKnowledgeView"
          }
        },
        "nodeId": {
          "type": "string"
        },
        "promises": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/PlayerPromiseView"
          }
        },
        "relationship": {
          "$ref": "#/$defs/RelationshipView"
        },
        "sceneId": {
          "type": "string"
        },
        "sceneTitle": {
          "type": "string"
        },
        "storyId": {
          "type": "string"
        },
        "suggestions": {
          "type": "array",
          "default": [],
          "items": {
            "$ref": "#/$defs/ActionSuggestion"
          }
        }
      },
      "required": [
        "storyId",
        "nodeId",
        "branchId",
        "sceneId",
        "sceneTitle",
        "characterName",
        "beats",
        "relationship",
        "canContinue"
      ]
    },
    "PresentationBeat": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "kind": {
          "$ref": "#/$defs/BeatKind"
        },
        "speaker": {
          "type": [
            "string",
            "null"
          ]
        },
        "text": {
          "type": "string"
        },
        "visual": {
          "anyOf": [
            {
              "$ref": "#/$defs/VisualDirective"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "kind",
        "text"
      ]
    },
    "PromiseStatus": {
      "type": "string",
      "enum": [
        "proposed",
        "accepted",
        "fulfilled",
        "broken",
        "released",
        "impossible"
      ]
    },
    "PromiseWeight": {
      "type": "string",
      "enum": [
        "minor",
        "major"
      ]
    },
    "RelationshipBand": {
      "type": "string",
      "enum": [
        "distant",
        "guarded",
        "warming",
        "close",
        "bonded"
      ]
    },
    "RelationshipView": {
      "type": "object",
      "properties": {
        "affinity": {
          "$ref": "#/$defs/RelationshipBand"
        },
        "attachment": {
          "$ref": "#/$defs/RelationshipBand"
        },
        "hope": {
          "$ref": "#/$defs/RelationshipBand"
        },
        "intimacy": {
          "$ref": "#/$defs/RelationshipBand"
        },
        "respect": {
          "$ref": "#/$defs/RelationshipBand"
        },
        "trust": {
          "$ref": "#/$defs/RelationshipBand"
        },
        "updatedAtNode": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "affinity",
        "trust",
        "hope",
        "respect",
        "intimacy",
        "attachment"
      ]
    },
    "VisualDirective": {
      "type": "object",
      "properties": {
        "character": {
          "type": [
            "string",
            "null"
          ]
        },
        "expression": {
          "type": [
            "string",
            "null"
          ]
        },
        "pose": {
          "type": [
            "string",
            "null"
          ]
        },
        "scene": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}
