diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a95bc88..145649b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,8 @@ To be released of a given user. * Added ``bots.handle_draw_offer`` and ``bots.handle_takeback_offer`` to handle draw and takeback offers * Added ``client.external_engine.analyse``, ``client.external_engine.acquire_request``, ``client.external_engine.answer_request`` to handle analysis with an external engine +* Added ``bots.claim_draw`` and ``bots.claim_victory`` to claim a draw or a victory in a bot game +* Added ``client.board.claim_draw`` to claim a draw in a game (after the opponent left the game) Thanks to all the contributors who helped to this release: @@ -29,6 +31,7 @@ Thanks to all the contributors who helped to this release: - @gameroman - @JAMoreno-Larios - @friedrichtenhagen +- @jquiaios v0.14.0 (2025-08-26) diff --git a/README.rst b/README.rst index c627f5e..7d2bf95 100644 --- a/README.rst +++ b/README.rst @@ -90,6 +90,7 @@ Most of the API is available: client.board.offer_takeback client.board.accept_takeback client.board.decline_takeback + client.board.claim_draw client.board.claim_victory client.board.go_berserk @@ -100,6 +101,8 @@ Most of the API is available: client.bots.post_message client.bots.abort_game client.bots.resign_game + client.bots.claim_draw + client.bots.claim_victory client.bots.handle_draw_offer client.bots.handle_takeback_offer client.bots.accept_challenge diff --git a/berserk/clients/board.py b/berserk/clients/board.py index bb4514e..7469201 100644 --- a/berserk/clients/board.py +++ b/berserk/clients/board.py @@ -119,6 +119,18 @@ def resign_game(self, game_id: str) -> None: path = f"/api/board/game/{game_id}/resign" self._r.post(path) + def claim_draw(self, game_id: str) -> None: + """Claim a draw when the opponent has left the game for a while. + + Generally, this should only be called once the `opponentGone` event + is received in the board game state stream and the `claimWinInSeconds` + time has elapsed. + + :param str game_id: ID of an in-progress game + """ + path = f"/api/board/game/{game_id}/claim-draw" + self._r.post(path) + def handle_draw_offer(self, game_id: str, accept: bool) -> None: """Create, accept, or decline a draw offer. diff --git a/berserk/clients/bots.py b/berserk/clients/bots.py index 44d6e6e..a56f7e1 100644 --- a/berserk/clients/bots.py +++ b/berserk/clients/bots.py @@ -78,6 +78,22 @@ def resign_game(self, game_id: str) -> None: path = f"/api/bot/game/{game_id}/resign" self._r.post(path) + def claim_draw(self, game_id: str) -> None: + """Claim a draw in a bot game. + + :param game_id: ID of a game + """ + path = f"/api/bot/game/{game_id}/claim-draw" + self._r.post(path) + + def claim_victory(self, game_id: str) -> None: + """Claim victory in a bot game. + + :param game_id: ID of a game + """ + path = f"/api/bot/game/{game_id}/claim-victory" + self._r.post(path) + def handle_draw_offer(self, game_id: str, accept: bool) -> None: """Create/accept/decline draw offers