{
  "openapi": "3.1.1",
  "info": {
    "title": "Draughts PDN Checker API",
    "version": "1.0.0",
    "summary": "Checks every move of a draughts or checkers game in PDN, with compulsory and majority captures.",
    "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://playcardsdraughtscheck.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Checks every move of a draughts or checkers game in PDN, with compulsory and majority captures.",
        "description": "Paste a game in Portable Draughts Notation (PDN) — international draughts on 10×10 or English checkers on 8×8 — and the checker replays it move by move with the full rules: capturing is compulsory, in international draughts the capture that takes the most pieces is required (majority rule) and kings fly, a man only becomes a king when its move ends on the far row. It names the first illegal move and why, lists every move with the captured pieces, gives the final position as FEN with the legal moves from there, and compares the Result tag with the position. The Playcards app imports PDN with the same engine.\n\nMethodology:\n- International draughts (FMJD): 10×10, 20 men each, White moves first. Men move one square diagonally forward and capture forward and backward; kings move and capture along whole diagonals (flying kings). Capturing is compulsory and the sequence that takes the most pieces must be chosen (kings and men count the same). Captured pieces are removed only after the move and cannot be jumped twice. A man that passes the far row during a capture and leaves it again stays a man.\n- English checkers (English Draughts Association / WCDF): 8×8, 12 men each, Black moves first. Men move and capture forward only; kings move and capture one square in every direction. Capturing is compulsory, but any capture may be chosen; a capture sequence must be completed, and a man that reaches the king row ends its move there.\n- Moves are matched in square numbers: a-b for moves, axb for captures (written with x, or with - in older files); when two captures lead between the same squares, the full path (axbxc) is required. Comments {…}, variations (…), NAGs and move numbers are skipped.\n- The position decides a result when the side to move has no legal move (it loses), after a threefold repetition, or after the quiet-move limit: 25 moves each with kings only and no capture (international) or 40 moves each without a capture or a man move (English). Special endgame limits of the FMJD rules (for example 16 moves for three kings against one) are not applied.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "playcards_draughts_check",
        "x-owner-app": "playcards",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlaycardsDraughtsCheckInput"
              },
              "examples": {
                "example1": {
                  "summary": "International opening with exchanges",
                  "value": {
                    "pdn": "[Event \"Example\"]\n[GameType \"20\"]\n[White \"Anna\"]\n[Black \"Ben\"]\n[Result \"*\"]\n\n1. 31-27 18-22 2. 27x18 12x23 3. 34-29 23x34 4. 40x29 20-24\n5. 29x20 15x24 6. 33-29 24x33 *"
                  }
                },
                "example2": {
                  "summary": "Majority rule broken (only one piece taken)",
                  "value": {
                    "variant": "international",
                    "pdn": "[FEN \"W:W28,33:B11,22,29\"]\n1. 33x24 *"
                  }
                },
                "example3": {
                  "summary": "English checkers: a missed capture",
                  "value": {
                    "variant": "english",
                    "pdn": "[GameType \"21\"]\n1. 11-15 22-18 2. 9-13 *"
                  }
                },
                "example4": {
                  "summary": "English checkers opening, legal",
                  "value": {
                    "pdn": "[GameType \"21\"]\n[Result \"*\"]\n1. 11-15 23-19 2. 8-11 22-17 3. 9-13 17-14 *"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlaycardsDraughtsCheckResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "PlaycardsDraughtsCheckInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "pdn": {
            "title": "PDN game",
            "description": "Tags in square brackets, then the moves in square numbers (32-28, 28x19, or the full path 28x19x10). [FEN \"W:W31,…:B1,…\"] sets up a position.",
            "type": "string",
            "maxLength": 200000,
            "default": "[Event \"Example\"]\n[GameType \"20\"]\n[White \"Anna\"]\n[Black \"Ben\"]\n[Result \"*\"]\n\n1. 31-27 18-22 2. 27x18 12x23 3. 34-29 23x34 4. 40x29 20-24\n5. 29x20 15x24 6. 33-29 24x33 *"
          },
          "variant": {
            "title": "Rules",
            "type": "string",
            "enum": [
              "auto",
              "international",
              "english"
            ],
            "default": "auto"
          }
        },
        "required": []
      },
      "PlaycardsDraughtsCheckResult": {
        "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": [
              "variant",
              "legal",
              "totalMoves",
              "checkedMoves",
              "firstIllegal",
              "startFen",
              "finalFen",
              "sideToMove",
              "legalMovesNext",
              "resultClaimed",
              "resultOnBoard",
              "moves",
              "pdn"
            ],
            "properties": {
              "variant": {
                "type": "string",
                "enum": [
                  "international",
                  "english"
                ]
              },
              "legal": {
                "type": "boolean"
              },
              "totalMoves": {
                "type": "integer"
              },
              "checkedMoves": {
                "type": "integer",
                "description": "Legal moves replayed before the first illegal one (or all)."
              },
              "firstIllegal": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "index",
                  "move",
                  "side",
                  "reason"
                ],
                "properties": {
                  "index": {
                    "type": "integer",
                    "description": "1-based half-move number."
                  },
                  "move": {
                    "type": "string"
                  },
                  "side": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                }
              },
              "startFen": {
                "type": "string"
              },
              "finalFen": {
                "type": "string"
              },
              "sideToMove": {
                "type": "string"
              },
              "legalMovesNext": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "resultClaimed": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "resultOnBoard": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "win/draw decided by the position (no legal move, repetition, quiet-move rule) or null while the game is open."
              },
              "moves": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "n",
                    "side",
                    "written",
                    "move",
                    "captured",
                    "crowned"
                  ],
                  "properties": {
                    "n": {
                      "type": "integer"
                    },
                    "side": {
                      "type": "string"
                    },
                    "written": {
                      "type": "string"
                    },
                    "move": {
                      "type": "string"
                    },
                    "captured": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      }
                    },
                    "crowned": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "pdn": {
                "type": "string",
                "description": "The legal part of the game as clean PDN."
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}