diff options
author | nea <romangraef@gmail.com> | 2022-11-27 21:32:34 +0100 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-11-27 21:32:34 +0100 |
commit | a75c2ec5addc65acd8bcb288b5fb89507bf8884c (patch) | |
tree | f29abf6605db36f5a18247cfd711eb9e6faed25b /server.py | |
parent | a091c4415d5153902f28e4bbbfeac3e5764b9019 (diff) | |
download | chess-a75c2ec5addc65acd8bcb288b5fb89507bf8884c.tar.gz chess-a75c2ec5addc65acd8bcb288b5fb89507bf8884c.tar.bz2 chess-a75c2ec5addc65acd8bcb288b5fb89507bf8884c.zip |
allow ending games
Diffstat (limited to 'server.py')
-rw-r--r-- | server.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -66,6 +66,10 @@ async def handle_socket(request: web.Request): numscore = score.relative.score(mate_score=100000) return abs(numscore) + if board.is_game_over(): + await send_to_user(dict(event="game_over", result=board.result())) + break + most_drawy_move: chess.engine.InfoDict = min(candidates, key=appraise) my_move: chess.Move = (most_drawy_move['pv'][0]) board.push(my_move) @@ -73,6 +77,9 @@ async def handle_socket(request: web.Request): event="computer_moved", lastmove=my_move.uci(), )) + if board.is_game_over(claim_draw=True): + await send_to_user(dict(event="game_over", result=board.result(claim_draw=True))) + break finally: if not ws.closed: |