txlyre 1 day ago
parent
commit
8a4bb7f19e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      chess0.py

+ 4 - 2
chess0.py

@@ -14,7 +14,7 @@ class IllegalMove(Exception):
 
 
 def outcome_to_str(outcome):
-    return f"{outcome.result()} {outcome.termination.name}"
+    return f"{outcome.result()}: {outcome.termination.name}"
 
 
 class ChessSession:
@@ -27,7 +27,9 @@ class ChessSession:
 
     def check_game_over(self):
         if self.board.is_game_over():
-            raise GameOver(f"{outcome_to_str(self.board.outcome())} {len(self.board.move_stack)}")
+            raise GameOver(f"{outcome_to_str(self.board.outcome())} [{len(self.board.move_stack)}]")
+        elif not self.board.is_valid():
+            raise GameOver(f"Некорректное состояние доски.")
 
     async def move(self, move=None):
         if move is not None: