From e37d2468e2b1a290e68d216d1eeb71348931149e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 11 Apr 2002 01:06:25 +0000 Subject: *** no comment *** --- chess-game.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'chess-game.el') diff --git a/chess-game.el b/chess-game.el index 35e41ce..3b55556 100644 --- a/chess-game.el +++ b/chess-game.el @@ -165,6 +165,14 @@ matches." (nconc plies (list ply)) (chess-game-set-plies game (list ply))))) +(defun chess-game-undo (game count) + "Undo the last COUNT plies of GAME." + (if (> count (chess-game-index game)) + (error "Cannot undo %d plies from a game with only %d plies" + count (chess-game-index game)) + (chess-game-set-plies game (nbutlast (chess-game-plies game) count)) + (chess-game-run-hooks game 'undo count))) + (defsubst chess-game-over-p (game) "Return the position related to GAME's INDEX position." @@ -205,7 +213,7 @@ progress (nil), if it is drawn, resigned, mate, etc." (error "Cannot add moves to a completed game")) (unless (equal position (chess-ply-pos current-ply)) (error "Positions do not match")) - (unless (or (chess-ply-has-keyword ply :resign) + (unless (or (chess-ply-has-keyword ply :resign :draw) (chess-search-position position (cadr (chess-ply-changes ply)) (chess-pos-piece position (car (chess-ply-changes ply))))) @@ -232,6 +240,10 @@ progress (nil), if it is drawn, resigned, mate, etc." "Resign the current game." (chess-game-move game (list (chess-game-pos game) :resign))) +(defsubst chess-game-draw (game) + "Draw the current game." + (chess-game-move game (list (chess-game-pos game) :draw))) + (provide 'chess-game) ;;; chess-game.el ends here -- cgit v1.2.3