From a0769011c2a98841156559aa37978156766cc09f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 10 Apr 2002 23:55:13 +0000 Subject: Added support for aborting a game. Use A or N from a display. --- chess-game.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'chess-game.el') diff --git a/chess-game.el b/chess-game.el index 995e741..35e41ce 100644 --- a/chess-game.el +++ b/chess-game.el @@ -101,11 +101,14 @@ matches." (nth 2 game)) (defun chess-game-set-data (game key value) - (let ((alist (chess-game-data-alist game))) - (if (null alist) - (setcar (nthcdr 2 game) (list (cons key value))) - (push (cons key value) alist) - (setcar (nthcdr 2 game) alist)) + (let* ((alist (chess-game-data-alist game)) + (cell (assq key alist))) + (if cell + (setcdr cell value) + (if (null alist) + (setcar (nthcdr 2 game) (list (cons key value))) + (push (cons key value) alist) + (setcar (nthcdr 2 game) alist))) (chess-game-run-hooks game 'set-data key))) (defun chess-game-data (game key) @@ -163,6 +166,12 @@ matches." (chess-game-set-plies game (list ply))))) +(defsubst chess-game-over-p (game) + "Return the position related to GAME's INDEX position." + (let ((last-ply (car (last game 2)))) + (and last-ply (chess-ply-final-p last-ply)))) + + (defsubst chess-game-to-string (game &optional indented) (chess-game-to-pgn game indented t)) -- cgit v1.2.3