diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-16 22:01:40 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-16 22:01:40 +0000 |
| commit | 42d3479f1b83a50714f7cbc17925ac0201a55022 (patch) | |
| tree | 3c1128dcd4a8b06db6674a2475b8c2b3866425f2 | |
| parent | 7c74ccf902b4a63128ee11db1e138a4eadfb7fd7 (diff) | |
Report checkmate in the modeline correctly.
| -rw-r--r-- | TODO | 5 | ||||
| -rw-r--r-- | chess-display.el | 11 | ||||
| -rw-r--r-- | chess-game.el | 10 | ||||
| -rw-r--r-- | chess-pos.el | 3 |
4 files changed, 22 insertions, 7 deletions
@@ -27,8 +27,13 @@ - Use chess-ply-set-keyword wherever keywords are being set now. +- Find a way that regexp-alist entries that only need to fire once are + only scanned once. + ---------------------------------------------------------------------- +- Need to implement the "50 moves after irreversible" draw rule + - The game should go inactive once I lose by stalemate/checkmate - When a clock runs down, indicate this in the modeline, and all the diff --git a/chess-display.el b/chess-display.el index 0bdbdaf..1ebe9ba 100644 --- a/chess-display.el +++ b/chess-display.el @@ -178,13 +178,12 @@ also view the same game." (chess-ply-to-algebraic (chess-game-ply chess-module-game (1- index))))) chess-display-side-to-move - (let ((final (chess-ply-final-p - (chess-game-ply chess-module-game index)))) + (let ((status (chess-game-status chess-module-game index))) (cond - ((eq final :checkmate) (chess-string 'mode-checkmate)) - ((eq final :resign) (chess-string 'mode-resigned)) - ((eq final :stalemate) (chess-string 'mode-stalemate)) - ((eq final :draw) (chess-string 'mode-drawn)) + ((eq status :resign) (chess-string 'mode-resigned)) + ((eq status :draw) (chess-string 'mode-drawn)) + ((eq status :checkmate) (chess-string 'mode-checkmate)) + ((eq status :stalemate) (chess-string 'mode-stalemate)) (t (if (chess-game-side-to-move chess-module-game) (chess-string 'mode-white) diff --git a/chess-game.el b/chess-game.el index 0e27fbd..f39a3e2 100644 --- a/chess-game.el +++ b/chess-game.el @@ -141,6 +141,16 @@ matches." "Return the position related to GAME's INDEX position." (chess-ply-pos (chess-game-ply game index))) +(defun chess-game-status (game &optional index) + "Return a symbol, such as :checkmate, :resign, etc. +This conveys the status of the game at the given index." + (or (car (chess-pos-status + (chess-game-pos chess-module-game index))) + (let ((final (chess-ply-final-p + (chess-game-ply chess-module-game index)))) + (and (memq final '(:resign :draw :perpetual :repetition)) + final)))) + (defsubst chess-game-index (game) "Return the GAME's current position index." (1- (length (chess-game-plies game)))) diff --git a/chess-pos.el b/chess-pos.el index 200fc97..ae12a93 100644 --- a/chess-pos.el +++ b/chess-pos.el @@ -132,7 +132,8 @@ SIDE must be either ?q or ?k (case determines color)." (defsubst chess-pos-status (position) "Return whether the side to move is in a special state. -The symbols allowed are: `check', `checkmate', `stalemate'. +The symbols allowed are: `check', `checkmate', `stalemate', which must +occurs first if they occur at all. Also, EPD evaluation numbers/strings can be set here." (aref position 69)) |
