summaryrefslogtreecommitdiff
path: root/chess-game.el
diff options
context:
space:
mode:
Diffstat (limited to 'chess-game.el')
-rw-r--r--chess-game.el15
1 files changed, 11 insertions, 4 deletions
diff --git a/chess-game.el b/chess-game.el
index ed38288..8b72035 100644
--- a/chess-game.el
+++ b/chess-game.el
@@ -75,13 +75,19 @@ matches."
(if (and (eq (caar h) function)
(or (null data)
(eq data (cdar h))))
- (if last-hook
- (setcdr last-hook (cdr h))
- (setq hooks (cdr h)))
+ (if last-hook
+ (setcdr last-hook (cdr h))
+ (setq hooks (cdr h)))
(setq last-hook h))
(setq h (cdr h)))
(chess-game-set-hooks game hooks)))
+(defun chess-game-get-hook-data (game function)
+ "Get list of corresponding data (nil if none) from all event hooks that match FUNCTION."
+ (cl-assert game)
+ (cl-assert function)
+ (cl-remove-if 'null (mapcar (lambda (h) (if (eq (car h) function) (cdr h))) (chess-game-hooks game))))
+
(defsubst chess-game-run-hooks (game &rest args)
"Run the event hooks of GAME and pass ARGS."
(cl-assert game)
@@ -337,7 +343,8 @@ progress (nil), if it is drawn, resigned, mate, etc."
(if (chess-ply-keyword ply :resign)
(chess-game-run-hooks game 'resign)
- (chess-game-run-hooks game 'move current-ply))))
+ (chess-game-run-hooks game 'move current-ply)
+ (chess-game-run-hooks game 'pre-move))))
(defsubst chess-game-end (game keyword)
"End GAME, by resignation, draw, etc."