{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "version": {
      "type": "number",
      "const": 1
    },
    "floor": {
      "type": "string",
      "pattern": "^#[a-fA-F0-9]{6}$"
    },
    "walls": {
      "type": "string",
      "pattern": "^#[a-fA-F0-9]{6}$"
    },
    "buildSize": {
      "type": "integer",
      "minimum": 56,
      "maximum": 384
    },
    "terrain": {
      "type": "object",
      "properties": {
        "preset": {
          "type": "string",
          "enum": [
            "meadow",
            "desert",
            "rocky"
          ]
        },
        "seed": {
          "type": "integer",
          "minimum": 0,
          "maximum": 2147483647
        },
        "size": {
          "type": "integer",
          "minimum": 128,
          "maximum": 512
        },
        "height": {
          "type": "number",
          "minimum": 0,
          "maximum": 28
        },
        "roughness": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      },
      "required": [
        "preset",
        "seed",
        "size",
        "height",
        "roughness"
      ],
      "additionalProperties": false
    },
    "background": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "sky",
            "lobby",
            "image"
          ]
        },
        "asset": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "yaw": {
          "type": "number",
          "minimum": -6.283185307179586,
          "maximum": 6.283185307179586
        }
      },
      "required": [
        "mode",
        "yaw"
      ],
      "additionalProperties": false
    },
    "skins": {
      "maxItems": 32,
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "version": {
                "type": "number",
                "const": 1
              },
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_-]{0,47}$"
              },
              "game": {
                "type": "string",
                "enum": [
                  "blackjack",
                  "blackjack_group",
                  "baccarat",
                  "dice",
                  "mines",
                  "keno",
                  "dragontower",
                  "limbo",
                  "plinko",
                  "coinflip",
                  "videopoker",
                  "roulette",
                  "crash",
                  "slots"
                ]
              },
              "contract": {
                "type": "string",
                "pattern": "^[a-f0-9]{16}$"
              },
              "body": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              },
              "bindings": {
                "maxItems": 32,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "slot": {
                      "type": "string",
                      "pattern": "^(?:control|part)\\.[a-z0-9_]{1,64}$"
                    },
                    "asset": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{64}$"
                    }
                  },
                  "required": [
                    "slot",
                    "asset"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "version",
              "id",
              "game",
              "contract",
              "body",
              "bindings"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "version": {
                "type": "number",
                "const": 2
              },
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_-]{0,47}$"
              },
              "game": {
                "type": "string",
                "enum": [
                  "blackjack",
                  "blackjack_group",
                  "baccarat",
                  "dice",
                  "mines",
                  "keno",
                  "dragontower",
                  "limbo",
                  "plinko",
                  "coinflip",
                  "videopoker",
                  "roulette",
                  "crash",
                  "slots"
                ]
              },
              "contract": {
                "type": "string",
                "pattern": "^[a-f0-9]{16}$"
              },
              "body": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              },
              "bindings": {
                "maxItems": 32,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "slot": {
                      "type": "string",
                      "pattern": "^(?:control|part)\\.[a-z0-9_]{1,64}$"
                    },
                    "asset": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{64}$"
                    }
                  },
                  "required": [
                    "slot",
                    "asset"
                  ],
                  "additionalProperties": false
                }
              },
              "placements": {
                "default": [],
                "maxItems": 34,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "target": {
                      "type": "string",
                      "pattern": "^(?:body|display|control\\.[a-z0-9_]{1,64})$"
                    },
                    "position": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "number",
                          "minimum": -4,
                          "maximum": 4
                        },
                        {
                          "type": "number",
                          "minimum": -4,
                          "maximum": 4
                        },
                        {
                          "type": "number",
                          "minimum": -4,
                          "maximum": 4
                        }
                      ],
                      "items": false,
                      "minItems": 3,
                      "maxItems": 3
                    },
                    "rotation": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "number",
                          "minimum": -12.566370614359172,
                          "maximum": 12.566370614359172
                        },
                        {
                          "type": "number",
                          "minimum": -12.566370614359172,
                          "maximum": 12.566370614359172
                        },
                        {
                          "type": "number",
                          "minimum": -12.566370614359172,
                          "maximum": 12.566370614359172
                        }
                      ],
                      "items": false,
                      "minItems": 3,
                      "maxItems": 3
                    },
                    "scale": {
                      "type": "array",
                      "prefixItems": [
                        {
                          "type": "number",
                          "minimum": 0.5,
                          "maximum": 2
                        },
                        {
                          "type": "number",
                          "minimum": 0.5,
                          "maximum": 2
                        },
                        {
                          "type": "number",
                          "minimum": 0.5,
                          "maximum": 2
                        }
                      ],
                      "items": false,
                      "minItems": 3,
                      "maxItems": 3
                    }
                  },
                  "required": [
                    "target",
                    "position",
                    "rotation",
                    "scale"
                  ],
                  "additionalProperties": false
                }
              },
              "clips": {
                "default": [],
                "maxItems": 16,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "target": {
                      "type": "string",
                      "pattern": "^(?:body|display|control\\.[a-z0-9_]{1,64})$"
                    },
                    "trigger": {
                      "type": "string",
                      "enum": [
                        "idle",
                        "result"
                      ]
                    },
                    "durationMs": {
                      "type": "integer",
                      "minimum": 200,
                      "maximum": 5000
                    },
                    "keyframes": {
                      "minItems": 2,
                      "maxItems": 32,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "time": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 1
                          },
                          "position": {
                            "type": "array",
                            "prefixItems": [
                              {
                                "type": "number",
                                "minimum": -4,
                                "maximum": 4
                              },
                              {
                                "type": "number",
                                "minimum": -4,
                                "maximum": 4
                              },
                              {
                                "type": "number",
                                "minimum": -4,
                                "maximum": 4
                              }
                            ],
                            "items": false,
                            "minItems": 3,
                            "maxItems": 3
                          },
                          "rotation": {
                            "type": "array",
                            "prefixItems": [
                              {
                                "type": "number",
                                "minimum": -12.566370614359172,
                                "maximum": 12.566370614359172
                              },
                              {
                                "type": "number",
                                "minimum": -12.566370614359172,
                                "maximum": 12.566370614359172
                              },
                              {
                                "type": "number",
                                "minimum": -12.566370614359172,
                                "maximum": 12.566370614359172
                              }
                            ],
                            "items": false,
                            "minItems": 3,
                            "maxItems": 3
                          },
                          "scale": {
                            "type": "array",
                            "prefixItems": [
                              {
                                "type": "number",
                                "minimum": 0.5,
                                "maximum": 2
                              },
                              {
                                "type": "number",
                                "minimum": 0.5,
                                "maximum": 2
                              },
                              {
                                "type": "number",
                                "minimum": 0.5,
                                "maximum": 2
                              }
                            ],
                            "items": false,
                            "minItems": 3,
                            "maxItems": 3
                          }
                        },
                        "required": [
                          "time",
                          "position",
                          "rotation",
                          "scale"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "target",
                    "trigger",
                    "durationMs",
                    "keyframes"
                  ],
                  "additionalProperties": false
                }
              },
              "motions": {
                "default": [],
                "maxItems": 4,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "channel": {
                      "type": "string",
                      "enum": [
                        "card_deal",
                        "card_flip",
                        "coin_flip",
                        "plinko_drop"
                      ]
                    },
                    "keyframes": {
                      "minItems": 2,
                      "maxItems": 32,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "time": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 1
                          },
                          "progress": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 1
                          },
                          "position": {
                            "type": "array",
                            "prefixItems": [
                              {
                                "type": "number",
                                "minimum": -2,
                                "maximum": 2
                              },
                              {
                                "type": "number",
                                "minimum": -2,
                                "maximum": 2
                              },
                              {
                                "type": "number",
                                "minimum": -2,
                                "maximum": 2
                              }
                            ],
                            "items": false,
                            "minItems": 3,
                            "maxItems": 3
                          },
                          "rotation": {
                            "type": "array",
                            "prefixItems": [
                              {
                                "type": "number",
                                "minimum": -25.132741228718345,
                                "maximum": 25.132741228718345
                              },
                              {
                                "type": "number",
                                "minimum": -25.132741228718345,
                                "maximum": 25.132741228718345
                              },
                              {
                                "type": "number",
                                "minimum": -25.132741228718345,
                                "maximum": 25.132741228718345
                              }
                            ],
                            "items": false,
                            "minItems": 3,
                            "maxItems": 3
                          }
                        },
                        "required": [
                          "time",
                          "progress",
                          "position",
                          "rotation"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "channel",
                    "keyframes"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "version",
              "id",
              "game",
              "contract",
              "body",
              "bindings",
              "placements",
              "clips",
              "motions"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "entities": {
      "maxItems": 1000000,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9:_-]{1,80}$"
          },
          "kind": {
            "type": "string",
            "enum": [
              "prop",
              "game"
            ]
          },
          "asset": {
            "type": "string",
            "maxLength": 80
          },
          "position": {
            "type": "array",
            "prefixItems": [
              {
                "type": "number",
                "minimum": -2048,
                "maximum": 2048
              },
              {
                "type": "number",
                "minimum": -2048,
                "maximum": 2048
              },
              {
                "type": "number",
                "minimum": -2048,
                "maximum": 2048
              }
            ],
            "items": false,
            "minItems": 3,
            "maxItems": 3
          },
          "yaw": {
            "type": "number",
            "minimum": -6.283185307179586,
            "maximum": 6.283185307179586
          },
          "scale": {
            "type": "array",
            "prefixItems": [
              {
                "type": "number",
                "minimum": 0.1,
                "maximum": 12
              },
              {
                "type": "number",
                "minimum": 0.1,
                "maximum": 12
              },
              {
                "type": "number",
                "minimum": 0.1,
                "maximum": 12
              }
            ],
            "items": false,
            "minItems": 3,
            "maxItems": 3
          },
          "color": {
            "type": "string",
            "pattern": "^#[a-fA-F0-9]{6}$"
          },
          "skin": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{0,47}$"
          }
        },
        "required": [
          "id",
          "kind",
          "asset",
          "position",
          "yaw",
          "scale",
          "color"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "version",
    "floor",
    "walls",
    "entities"
  ],
  "additionalProperties": false
}
