diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-07 09:35:05 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-07 09:35:05 +0000 |
| commit | 1198bebb0e77e0a6e687f1bc01ad0bc868cedf68 (patch) | |
| tree | e961609dc961816392fd924a6647a72e3d0791b9 /chess-game.el | |
| parent | 7ef0297f2478f3fc4e7d684706806e30b6109c22 (diff) | |
Games are now playable to the end.
Diffstat (limited to 'chess-game.el')
| -rw-r--r-- | chess-game.el | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/chess-game.el b/chess-game.el index fd3c5fa..6abdc20 100644 --- a/chess-game.el +++ b/chess-game.el @@ -129,7 +129,7 @@ (defsubst chess-game-pos (game &optional index) "Return the position related to GAME's INDEX position." - (car (chess-game-ply game index))) + (chess-ply-pos (chess-game-ply game index))) (defun chess-game-create (&optional position search-func tags) @@ -166,19 +166,23 @@ progress (nil), if it is drawn, resigned, mate, etc." (chess-pos-piece position (car (chess-ply-changes ply)))) (signal 'chess-illegal "Illegal move")) (chess-ply-set-changes current-ply changes) + (chess-game-add-ply game (chess-ply-create + (chess-ply-next-pos current-ply))) (cond ((or (memq ':draw changes) (memq ':perpetual changes) (memq ':repetition changes) (memq ':stalemate changes)) - (chess-game-set-tag game "Result" "1/2-1/2")) + (chess-game-set-tag game "Result" "1/2-1/2") + (chess-game-run-hooks game 'game-over)) + ((or (memq ':resign changes) (memq ':checkmate changes)) (chess-game-set-tag game "Result" (if (chess-game-side-to-move game) - "0-1" "1-0"))) + "0-1" "1-0")) + (chess-game-run-hooks game 'game-over)) + (t - (chess-game-add-ply game (chess-ply-create - (chess-ply-next-pos current-ply))) (chess-game-run-hooks game 'move current-ply))))) ;; A few convenience functions |
