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()