[gnome-chess/gnome-3-36] Avoid showing claim draw dialog before forced draw



commit b68b19b829741f36453332c3ab50a77457a2613d
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Thu Oct 15 09:13:11 2020 -0500

    Avoid showing claim draw dialog before forced draw
    
    If we've repeated the same move enough times, we display the claim draw
    dialog immediately before ending the game due to the forced draw. This
    is wrong: the game is already over, but the user is still prompted to
    decide whether to claim draw or not! That's no good.

 lib/chess-game.vala | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/lib/chess-game.vala b/lib/chess-game.vala
index 154d252..528c9f5 100644
--- a/lib/chess-game.vala
+++ b/lib/chess-game.vala
@@ -249,7 +249,8 @@ public class ChessGame : Object
 
     public bool is_three_fold_repeat ()
     {
-        return state_repeated_times (current_state) >= 3;
+        var repeated = state_repeated_times (current_state);
+        return repeated == 3 || repeated == 4;
     }
 
     public bool is_five_fold_repeat ()
@@ -260,7 +261,7 @@ public class ChessGame : Object
     public bool is_fifty_move_rule_fulfilled ()
     {
         /* Fifty moves *per player* without capture or pawn advancement */
-        return current_state.halfmove_clock >= 100;
+        return current_state.halfmove_clock >= 100 && current_state.halfmove_clock < 150;
     }
 
     public bool is_seventy_five_move_rule_fulfilled ()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]