diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-17 08:34:35 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-17 08:34:35 +0000 |
| commit | c171394743d2a10cfe872ce076c5a8f7269d7b2b (patch) | |
| tree | 0906d6eb3a7d9e6367e22d32ea1158db2d759f53 /chess-game.el | |
| parent | 4d1c4c72b5a9c2c0180531246389a452fc034bc8 (diff) | |
More general bug fixing, efficiency improvements, etc.
Diffstat (limited to 'chess-game.el')
| -rw-r--r-- | chess-game.el | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/chess-game.el b/chess-game.el index a34d6a3..43a62e5 100644 --- a/chess-game.el +++ b/chess-game.el @@ -232,24 +232,30 @@ progress (nil), if it is drawn, resigned, mate, etc." (let ((current-ply (chess-game-ply game)) (changes (chess-ply-changes ply)) (position (chess-ply-pos ply))) + (if (chess-ply-final-p current-ply) (chess-error 'add-to-completed)) + (assert (equal position (chess-ply-pos current-ply))) (chess-ply-set-changes current-ply changes) (chess-game-add-ply game (chess-ply-create* (chess-ply-next-pos current-ply) t)) - (if (> (length changes) 2) - (if (chess-ply-any-keyword ply :resign :checkmate) - (let ((color (chess-game-side-to-move game))) - (chess-game-set-tag game "Result" (if color "0-1" "1-0")) - (if (chess-ply-keyword ply :resign) - (chess-game-run-hooks game 'resign color) - (chess-game-run-hooks game 'move current-ply))) - (when (chess-ply-any-keyword ply :draw :perpetual :repetition - :stalemate) - (chess-game-set-tag game "Result" "1/2-1/2") - (chess-game-run-hooks game 'drawn))) - (chess-game-run-hooks game 'move current-ply)) + + (let ((long (> (length changes) 2))) + (cond + ((and long (chess-ply-any-keyword ply :resign :checkmate)) + (let ((color (chess-game-side-to-move game))) + (chess-game-set-tag game "Result" (if color "0-1" "1-0")) + (if (chess-ply-keyword ply :resign) + (chess-game-run-hooks game 'resign color) + (chess-game-run-hooks game 'move current-ply)))) + ((and long (chess-ply-any-keyword ply :draw :perpetual :repetition + :stalemate)) + (chess-game-set-tag game "Result" "1/2-1/2") + (chess-game-run-hooks game 'drawn)) + (t + (chess-game-run-hooks game 'move current-ply)))) + (chess-game-run-hooks game 'post-move))) (defsubst chess-game-end (game keyword) |
