From 57e4b8489f9691bcba689d9e58c9a74900d9d381 Mon Sep 17 00:00:00 2001 From: Tibor Bizjak Date: Sun, 26 Feb 2023 23:34:11 +0100 Subject: [PATCH] Forgot to commit --- chess.py | 6 +++--- main.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/chess.py b/chess.py index ddc70c6..7d342cd 100644 --- a/chess.py +++ b/chess.py @@ -490,7 +490,6 @@ class Game: the move puts the player in check.""" new = deepcopy(self) valid = new.move(source, dest, promotion) - new.turn = self.turn return valid, new def AN_move(self, move): @@ -517,8 +516,9 @@ class Game: moves = [] for sq in sqrs: valid, new = self.validate_move(sq, dest, promotion) - check = new.is_check()==info.check and new.is_mate()==info.mate - if valid and check: + check = new.is_check()==info.check + mate = new.is_mate()==info.mate + if valid and (check or mate): moves.append((sq, dest, promotion)) if len(moves) != 1: return False diff --git a/main.py b/main.py index 120d1d6..7eb89de 100644 --- a/main.py +++ b/main.py @@ -34,7 +34,8 @@ def move(): id = request.get_cookie("gameid", secret=KEY) valid = True if is_submitted("newgame"): - del games[id] + if id in games: + del games[id] redirect("/") if is_submitted("prev"): games[id].prev()