gnome-games r8406 - in trunk/glchess/src/lib: . gtkui
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8406 - in trunk/glchess/src/lib: . gtkui
- Date: Mon, 5 Jan 2009 22:49:04 +0000 (UTC)
Author: rancell
Date: Mon Jan 5 22:49:04 2009
New Revision: 8406
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8406&view=rev
Log:
Make resigning in a UI versus UI game abandon the game (there was no way previously to stop these games)
Modified:
trunk/glchess/src/lib/display.py
trunk/glchess/src/lib/game.py
trunk/glchess/src/lib/gtkui/chessview.py
trunk/glchess/src/lib/main.py
Modified: trunk/glchess/src/lib/display.py
==============================================================================
--- trunk/glchess/src/lib/display.py (original)
+++ trunk/glchess/src/lib/display.py Mon Jan 5 22:49:04 2009
@@ -557,7 +557,10 @@
def resign(self):
"""Called by ui.ViewFeedback"""
p = self.game.getHumanPlayer()
- if p is not None:
+ if p is None:
+ # If no human players then abandon game
+ self.game.abandon()
+ else:
p.resign()
def claimDraw(self):
Modified: trunk/glchess/src/lib/game.py
==============================================================================
--- trunk/glchess/src/lib/game.py (original)
+++ trunk/glchess/src/lib/game.py Mon Jan 5 22:49:04 2009
@@ -25,6 +25,7 @@
RULE_RESIGN = 'RESIGN'
RULE_DEATH = 'DEATH'
RULE_AGREEMENT = 'AGREEMENT'
+RULE_ABANDONMENT = 'ABANDONMENT'
class ChessMove:
"""
@@ -685,6 +686,9 @@
else:
assert(False)
self.endGame(result, RULE_TIMEOUT)
+
+ def abandon(self):
+ self.endGame(RESULT_DRAW, RULE_ABANDONMENT)
def endGame(self, result, rule):
if self.result != RESULT_IN_PROGRESS:
Modified: trunk/glchess/src/lib/gtkui/chessview.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/chessview.py (original)
+++ trunk/glchess/src/lib/gtkui/chessview.py Mon Jan 5 22:49:04 2009
@@ -611,6 +611,9 @@
description = _('The white player has resigned')
else:
assert(False)
+ elif game.rule is glchess.game.RULE_ABANDONMENT:
+ # Translators: Message displayed when a game is abandoned
+ description = _('The game has been abandoned')
elif game.rule is glchess.game.RULE_DEATH:
# Translators: Message displayed when the game ends due to a player dying
description = _('One of the players has died')
Modified: trunk/glchess/src/lib/main.py
==============================================================================
--- trunk/glchess/src/lib/main.py (original)
+++ trunk/glchess/src/lib/main.py Mon Jan 5 22:49:04 2009
@@ -225,9 +225,9 @@
else:
pgnGame.setTag(chess.pgn.TAG_RESULT, value)
- rules = {game.RULE_RESIGN: chess.pgn.TERMINATE_ABANDONED,
- game.RULE_TIMEOUT: chess.pgn.TERMINATE_TIME_FORFEIT,
- game.RULE_DEATH: chess.pgn.TERMINATE_DEATH}
+ rules = {game.RULE_ABANDONMENT: chess.pgn.TERMINATE_ABANDONED,
+ game.RULE_TIMEOUT: chess.pgn.TERMINATE_TIME_FORFEIT,
+ game.RULE_DEATH: chess.pgn.TERMINATE_DEATH}
try:
value = rules[self.rule]
except KeyError:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]