diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-13 01:14:32 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-13 01:14:32 +0000 |
| commit | 3ab3e41f5023e699e56d9b5171264c5e62854540 (patch) | |
| tree | e9efa453c7b2422034f1ab4e85bf10ae221fa5a2 /chess-ply.el | |
| parent | 1b173a311002cdd6fa0b0f0dee916815e513f1ed (diff) | |
*** no comment ***
Diffstat (limited to 'chess-ply.el')
| -rw-r--r-- | chess-ply.el | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/chess-ply.el b/chess-ply.el index ea6e0ac..80894cb 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -63,17 +63,28 @@ (defsubst chess-ply-set-changes (ply changes) (setcdr ply changes)) -(defun chess-ply-has-keyword (ply &rest keywords) +(defun chess-ply-any-keyword (ply &rest keywords) (catch 'found (dolist (keyword keywords) (if (memq keyword (chess-ply-changes ply)) (throw 'found keyword))))) +(defun chess-ply-keyword (ply keyword) + (let ((item (memq keyword (chess-ply-changes ply)))) + (if item + (if (memq keyword '(:which :promote)) + (cdr item) + t)))) + (defsubst chess-ply-source (ply) - (car (chess-ply-changes ply))) + (let ((changes (chess-ply-changes ply))) + (and (listp changes) (not (symbolp (car changes))) + (car changes)))) (defsubst chess-ply-target (ply) - (cadr (chess-ply-changes ply))) + (let ((changes (chess-ply-changes ply))) + (and (listp changes) (not (symbolp (car changes))) + (cadr changes)))) (defsubst chess-ply-next-pos (ply) (apply 'chess-pos-move (chess-pos-copy (chess-ply-pos ply)) @@ -206,7 +217,7 @@ maneuver." (defsubst chess-ply-final-p (ply) "Return non-nil if this is the last ply of a game/variation." - (chess-ply-has-keyword ply :draw :perpetual :repetition :stalemate + (chess-ply-any-keyword ply :draw :perpetual :repetition :stalemate :resign :checkmate)) (defun chess-legal-plies (position) |
