diff options
author | Andrés Ambrois <andresambrois@gmail.com> | 2008-07-21 21:27:55 (GMT) |
---|---|---|
committer | Andrés Ambrois <andresambrois@gmail.com> | 2008-07-21 21:27:55 (GMT) |
commit | c8361dee621ec1b3c236b5ba1f5f7b93fc9fd5b9 (patch) | |
tree | 166706d5ad700579d5b71900f89e69032ecc2863 /boardwidget.py | |
parent | dae14728a595cd960c1874e437aafb9b9dc62bdd (diff) |
Fixes and additions: Scorekeeping, basic Ko, Illegal moves, messages
Diffstat (limited to 'boardwidget.py')
-rwxr-xr-x | boardwidget.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/boardwidget.py b/boardwidget.py index 95e19fd..4ea9cdd 100755 --- a/boardwidget.py +++ b/boardwidget.py @@ -99,8 +99,13 @@ class BoardWidget(gtk.EventBox): assert y < self.myBoard.size self.myBoard.setPointi( x, y, color ) + self.update_score(self.myBoard.score) return None - + + def update_score(self, score): + if score == 0: + return 0 + self.activity.info_panel.show_score(_("Score is: Whites %(W)d - Blacks %(B)d" % score)) # def remove(self, column, value): # """Return: @@ -215,14 +220,20 @@ class BoardWidget(gtk.EventBox): boolean check if the stone play is legal """ if self.myBoard.status.has_key( (x,y) ) : + self.activity.info_panel.show(_("There already is a stone there!")) return False c = 'W' if self.lastColor is 1 : c = 'B' -# if not self.myBoard.legal( (x,y), c ) : -# return False + if not self.myBoard.legal( (x,y), c ) : + self.activity.info_panel.show(_("Illegal move")) + return False + + if self.myBoard.checkKo( (x, y), c): + self.activity.info_panel.show(_("Ko violation!")) + return False logger.debug( " returning legal ") return True |