{
  "openapi": "3.1.1",
  "info": {
    "title": "Pinball Table Checker API",
    "version": "1.0.0",
    "summary": "Validate a Pinquest pinball table and prove every mission goal can be reached by a bot.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://pinquesttablecheck.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Validate a Pinquest pinball table and prove every mission goal can be reached by a bot.",
        "description": "Checks a Pinquest table — a built-in one or your own table JSON — for errors (unknown elements, broken references, missing flippers or plunger, invalid rules), then lets the autoplay bot play every mission stage with the real physics to prove each goal can be reached, and reports stuck balls, free-play scores and switches the ball never touched.\n\nMethodology:\n- Validation follows the Pinquest table format: ids, element types and their geometry in table units (x 0–20, y 0–40), exactly one plunger, at least one left and one right flipper, known lights, drop banks, missions, variables and achievements in every rule, and well-formed conditions and actions.\n- Physics: fixed steps of 1/240 s with sub-steps so no ball or flipper tip moves more than 0.35 ball radii per sub-step; walls, posts, bumpers, slingshots and targets use swept-circle time of impact, so the ball cannot tunnel through them; flippers transfer their surface speed to the ball.\n- For every mission stage the bot starts that mission at that stage as soon as a ball is in play and plays up to the given number of balls (games of 5 balls). A stage is reachable when the bot completes it once. The bot flips when a ball is about to reach a flipper, varies its timing to aim, cradles some balls and pulls the plunger with random strength — it is a fair but imperfect player, so \"not reached\" means \"hard\", not \"impossible\".\n- Free play: three whole games with the bot; ball searches count balls that stopped moving for 5 s (a sign of a ball trap); switches never touched are listed so you can spot shots no flipper can make.\n\nA game-design aid for Pinquest tables, not a model of a real pinball machine.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "pinquest_table_check",
        "x-owner-app": "pinquest",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PinquestTableCheckInput"
              },
              "examples": {
                "example1": {
                  "summary": "Witch of the King's Castle (reference table)",
                  "value": {
                    "table": "witch-castle",
                    "tableJson": "",
                    "balls": 6,
                    "seed": 1
                  }
                },
                "example2": {
                  "summary": "Zombie Night with a strict proof",
                  "value": {
                    "table": "zombie-night",
                    "tableJson": "",
                    "balls": 8,
                    "seed": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PinquestTableCheckResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "PinquestTableCheckInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "table": {
            "title": "Table",
            "type": "string",
            "enum": [
              "witch-castle",
              "zombie-night",
              "pirate-treasure",
              "space-station",
              "dragon-lair",
              "haunted-circus",
              "deep-sea",
              "jungle-temple",
              "steampunk-airship",
              "ninja-dojo",
              "wild-west-heist",
              "alien-invasion",
              "dinosaur-island",
              "candy-kingdom",
              "robot-factory",
              "viking-saga",
              "egyptian-tomb",
              "cyber-city",
              "fairy-forest",
              "volcano-forge",
              "arctic-expedition",
              "monster-carnival",
              "superhero-city",
              "detective-noir",
              "mad-science-lab",
              "samurai-storm",
              "moon-base",
              "wizard-school",
              "kaiju-attack",
              "atlantis",
              "sky-islands",
              "ghost-train"
            ],
            "default": "witch-castle"
          },
          "tableJson": {
            "title": "Your own table (Pinquest table JSON, optional — replaces the table above)",
            "description": "The format is described in the Pinquest table spec: elements (walls, flippers, bumpers, ramps …) in table units (20 × 40), lights and rules with missions.",
            "type": "string",
            "maxLength": 200000,
            "default": ""
          },
          "balls": {
            "title": "Simulated balls per mission stage",
            "description": "More balls = a stricter proof but a longer check. A stage counts as reachable as soon as the bot finishes it once.",
            "type": "integer",
            "minimum": 1,
            "maximum": 40,
            "default": 10
          },
          "seed": {
            "title": "Random seed of the bot",
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000,
            "default": 1
          }
        },
        "required": []
      },
      "PinquestTableCheckResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "table",
              "valid",
              "issues",
              "counts",
              "missions",
              "stages",
              "stageChecks",
              "allGoalsReached",
              "freePlay",
              "unreachedSwitches"
            ],
            "properties": {
              "table": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "id",
                  "title",
                  "theme",
                  "style"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "theme": {
                    "type": "string"
                  },
                  "style": {
                    "type": "string"
                  }
                }
              },
              "valid": {
                "type": "boolean"
              },
              "issues": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "level",
                    "path",
                    "message"
                  ],
                  "properties": {
                    "level": {
                      "enum": [
                        "error",
                        "warning"
                      ]
                    },
                    "path": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              },
              "counts": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              },
              "missions": {
                "type": "integer"
              },
              "stages": {
                "type": "integer"
              },
              "stageChecks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "mission",
                    "title",
                    "stage",
                    "text",
                    "goals",
                    "reached",
                    "seconds",
                    "ballsUsed"
                  ],
                  "properties": {
                    "mission": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "stage": {
                      "type": "integer"
                    },
                    "text": {
                      "type": "string"
                    },
                    "goals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "on",
                          "count"
                        ],
                        "properties": {
                          "on": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "reached": {
                      "type": "boolean"
                    },
                    "seconds": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "ballsUsed": {
                      "type": "integer"
                    }
                  }
                }
              },
              "allGoalsReached": {
                "type": "boolean"
              },
              "freePlay": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "games",
                  "meanScore",
                  "meanSeconds",
                  "ballSearches",
                  "drains",
                  "missionsStarted",
                  "missionsDone"
                ],
                "properties": {
                  "games": {
                    "type": "integer"
                  },
                  "meanScore": {
                    "type": "integer"
                  },
                  "meanSeconds": {
                    "type": "number"
                  },
                  "ballSearches": {
                    "type": "integer"
                  },
                  "drains": {
                    "type": "integer"
                  },
                  "missionsStarted": {
                    "type": "integer"
                  },
                  "missionsDone": {
                    "type": "integer"
                  }
                }
              },
              "unreachedSwitches": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}