Skip to content

Conversation

@tors42
Copy link
Contributor

@tors42 tors42 commented Aug 18, 2024

Background: Swiss tournaments can have custom positions, i.e games start from a FEN.

Problem: In the API, there is no "position" field in the "create swiss" and "get swiss" operations.

Suggestion: Include "position" field when a custom position exists.

Reproducers:

Create (needs existing team id, here 'yulias')

$ curl \
    -d 'rated=false&clock.limit=180&clock.increment=2&nbRounds=3&variant=standard&position=rnbqkbnr%2Fpppp1ppp%2F4p3%2F8%2F4P3%2F8%2FPPPP1PPP%2FRNBQKBNR+w+KQkq+-' \
    -H "authorization: Bearer lip_yulia" \
    http://localhost:8080/api/swiss/new/yulias | jq
create response
{
  "id": "2wexQyFc",
  "createdBy": "yulia",
  "startsAt": "2024-08-18T08:57:41.030552736Z",
  "name": "Gunina",
  "clock": {
    "limit": 180,
    "increment": 2
  },
  "variant": "standard",
  "round": 0,
  "nbRounds": 3,
  "nbPlayers": 0,
  "nbOngoing": 0,
  "status": "created",
  "nextRound": {
    "at": "2024-08-18T08:57:41.03049833Z",
    "in": 600
  },
  "verdicts": {
    "list": [],
    "accepted": true
  },
  "stats": null,
  "rated": false
}

Get (needs existing swiss id, here '2wexQyFc')

$ curl http://localhost:8080/api/swiss/2wexQyFc | jq
get response
{
  "id": "2wexQyFc",
  "createdBy": "yulia",
  "startsAt": "2024-08-18T08:57:41.03Z",
  "name": "Gunina",
  "clock": {
    "limit": 180,
    "increment": 2
  },
  "variant": "standard",
  "round": 0,
  "nbRounds": 3,
  "nbPlayers": 0,
  "nbOngoing": 0,
  "status": "created",
  "nextRound": {
    "at": "2024-08-18T08:57:41.03Z",
    "in": 567
  },
  "verdicts": {
    "list": [],
    "accepted": true
  },
  "stats": null,
  "rated": false
}

With the commit included:

$ curl \
    -d 'rated=false&clock.limit=180&clock.increment=2&nbRounds=3&variant=standard&position=rnbqkbnr%2Fpppp1ppp%2F4p3%2F8%2F4P3%2F8%2FPPPP1PPP%2FRNBQKBNR+w+KQkq+-' \
    -H "authorization: Bearer lip_yulia" \
    http://localhost:8080/api/swiss/new/yulias | jq
create response - known/named FEN
{
  "id": "UvF9ICqp",
  "createdBy": "yulia",
  "startsAt": "2024-08-18T08:59:57.075598264Z",
  "name": "Palme",
  "clock": {
    "limit": 180,
    "increment": 2
  },
  "variant": "standard",
  "round": 0,
  "nbRounds": 3,
  "nbPlayers": 0,
  "nbOngoing": 0,
  "status": "created",
  "nextRound": {
    "at": "2024-08-18T08:59:57.075545288Z",
    "in": 600
  },
  "position": {
    "eco": "C00",
    "name": "French Defense",
    "fen": "rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq -",
    "url": "https://lichess.org/opening/French_Defense"
  },
  "verdicts": {
    "list": [],
    "accepted": true
  },
  "stats": null,
  "rated": false
}
$ curl \
    -d 'rated=false&clock.limit=180&clock.increment=2&nbRounds=3&variant=standard&position=rnbqkbnr%2F8%2F8%2F8%2F8%2F8%2F8%2FRNBQKBNR+w+KQkq+-' \
    -H "authorization: Bearer lip_yulia" \
    http://localhost:8080/api/swiss/new/yulias | jq
create response - no pawns FEN
{
  "id": "Zra2y6CI",
  "createdBy": "yulia",
  "startsAt": "2024-08-18T09:01:49.545046494Z",
  "name": "Szabó",
  "clock": {
    "limit": 180,
    "increment": 2
  },
  "variant": "standard",
  "round": 0,
  "nbRounds": 3,
  "nbPlayers": 0,
  "nbOngoing": 0,
  "status": "created",
  "nextRound": {
    "at": "2024-08-18T09:01:49.545033073Z",
    "in": 600
  },
  "position": {
    "name": "Custom position",
    "fen": "rnbqkbnr/8/8/8/8/8/8/RNBQKBNR w KQkq -"
  },
  "verdicts": {
    "list": [],
    "accepted": true
  },
  "stats": null,
  "rated": false
}

@ornicar ornicar merged commit 9d79cde into lichess-org:master Aug 19, 2024
@tors42 tors42 deleted the api-position-swiss branch August 19, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants