diff --git a/mastochess.py b/mastochess.py index 7de46b0..fbaccaf 100644 --- a/mastochess.py +++ b/mastochess.py @@ -681,7 +681,7 @@ def send_anotation(game_id): return (emailed, game_id, game_found) -def close_game(username): +def close_game(username, checkmate): try: @@ -729,6 +729,10 @@ def close_game(username): winner = 'none' + if checkmate: + + winner = username + else: if query_word == search_end and username == white_user and stalemate == False: @@ -1592,12 +1596,12 @@ if __name__ == '__main__': game_moves = board.ply() - close_game(username) - if stalemate == False: checkmate = True + close_game(username, checkmate) + else: checkmate = False @@ -1718,6 +1722,8 @@ if __name__ == '__main__': stalemate = False + checkmate = False + if black_user != '': if username == white_user: @@ -1726,7 +1732,7 @@ if __name__ == '__main__': mastodon.status_post(toot_text, in_reply_to_id=status_id,visibility=visibility) - close_game(username) + close_game(username, checkmate) update_replies(status_id, username, now) @@ -1740,7 +1746,7 @@ if __name__ == '__main__': mastodon.status_post(toot_text, in_reply_to_id=status_id,visibility=visibility) - close_game(username) + close_game(username, checkmate) update_replies(status_id, username, now) @@ -1754,7 +1760,7 @@ if __name__ == '__main__': mastodon.status_post(toot_text, in_reply_to_id=status_id, visibility=visibility) - close_game(username) + close_game(username, checkmate) update_replies(status_id, username, now)