Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-09-07 16:41:21 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-09-07 16:41:21 (GMT)
commite57f928267e64b526bd39efe1399a49705c4414e (patch)
treed1da4aa0f354dc83496534c1411cb90c624b169a
parent83532aa6f2ac611d9f7e07c741ce4beb1dcba1b3 (diff)
prevent robot from playing wrong color after illegal move
-rw-r--r--chess.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/chess.py b/chess.py
index 75cbf91..831d7ce 100644
--- a/chess.py
+++ b/chess.py
@@ -373,7 +373,7 @@ class Gnuchess():
return
elif self._activity.playing_white and \
len(self.move_list) % 2 == 1:
- self._wait_your_turn()
+ self._wait_your_turn()
return
# Only play your color
@@ -493,6 +493,17 @@ class Gnuchess():
self._flash_tile([self._xy_to_file_and_rank(
self.black[4].get_xy())])
+ # Check to see if it is the robot's turn
+ if self._activity.playing_robot and \
+ self._activity.playing_white and \
+ len(self.move_list) % 2 == 0:
+ _logger.debug("not the robot's turn")
+ return True
+ if self._activity.playing_robot and \
+ not self._activity.playing_white and \
+ len(self.move_list) % 2 == 1:
+ _logger.debug("not the robot's turn")
+ return True
if self._activity.playing_robot and not self.checkmate:
self._activity.set_thinking_cursor()
self._activity.status.set_label(_('Thinking...'))