Skip to content

shows match winner#58

Open
kakdeykaushik wants to merge 1 commit intoWintrCat:masterfrom
kakdeykaushik:show-winner
Open

shows match winner#58
kakdeykaushik wants to merge 1 commit intoWintrCat:masterfrom
kakdeykaushik:show-winner

Conversation

@kakdeykaushik
Copy link
Copy Markdown

@kakdeykaushik kakdeykaushik commented Jan 18, 2025

Shows match winner or draw in the Select a game modal for both chesscom and lichess.

Chesscom API returns stalemate if match is drawn in player's object, otherwise win in result field of winner's object and resigned, checkmated etc in losers result field.

{
    ...
    "white": {
        "rating": 312,
        "result": "stalemate",
        "@id": "https://api.chess.com/pub/player/heidelwurst",
        "username": "Heidelwurst",
        "uuid": "01991e62-f3cc-11eb-872b-f70fdab2764c"
    },
    "black": {
        "rating": 457,
        "result": "stalemate",
        "@id": "https://api.chess.com/pub/player/kaushik23456",
        "username": "kaushik23456",
        "uuid": "12466a44-b4c9-11ec-ba0a-299867be4d7a"
    }
    ...
}
{
    ...
    "white": {
        "rating": 232,
        "result": "checkmated",
        "@id": "https://api.chess.com/pub/player/shivamkapapa",
        "username": "SHIVAMKAPAPA",
        "uuid": "e338e8d4-d596-11ea-ba27-830062a3c426"
    },
    "black": {
        "rating": 440,
        "result": "win",
        "@id": "https://api.chess.com/pub/player/kaushik23456",
        "username": "kaushik23456",
        "uuid": "12466a44-b4c9-11ec-ba0a-299867be4d7a"
    }
    ...
}

Lichess API returns status as draw when match is drawn. When there is a winner it returns color in winner field of the game.

{
    ...
    "status": "draw",
    "players": {
        "white": {
            "user": {
                "name": "SindarovGM",
                "title": "GM",
                "id": "sindarovgm"
            },
            "rating": 3224,
            "ratingDiff": -3
        },
        "black": {
            "user": {
                "name": "Andrey11976",
                "title": "NM",
                "id": "andrey11976"
            },
            "rating": 3077,
            "ratingDiff": 2
        }
    }
    ...
}
{
    ...
    "status": "mate",
    "players": {
        "white": {
            "user": {
                "name": "Heisenberg01",
                "title": "FM",
                "id": "heisenberg01"
            },
            "rating": 3129,
            "ratingDiff": -4
        },
        "black": {
            "user": {
                "name": "SindarovGM",
                "title": "GM",
                "id": "sindarovgm"
            },
            "rating": 3221,
            "ratingDiff": 6
        }
    },
    "winner": "black"
    ...
}

chesscom
Screenshot 2025-01-18 at 15 56 37

lichess
Screenshot 2025-01-18 at 15 57 51

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.

1 participant