diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-15 05:40:38 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-15 05:40:38 +0000 |
| commit | ef7c29d679c6aaf8dda55772e65800097c46f163 (patch) | |
| tree | 543f39f09bfaa6d44606804c18babff26470d4f8 /chess-gnuchess.el | |
| parent | 6fbcc92505250d896b5d408483822b115bc614c7 (diff) | |
*** no comment ***
Diffstat (limited to 'chess-gnuchess.el')
| -rw-r--r-- | chess-gnuchess.el | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/chess-gnuchess.el b/chess-gnuchess.el index 225ee30..32c4030 100644 --- a/chess-gnuchess.el +++ b/chess-gnuchess.el @@ -38,40 +38,43 @@ ;; "go" after the user's move (setq chess-gnuchess-bad-board t)))))) -(defun chess-gnuchess-handler (event &rest args) - (cond - ((eq event 'initialize) - (let ((proc (chess-common-handler 'initialize "gnuchess"))) - (process-send-string proc "nopost\n") - proc)) +(defun chess-gnuchess-handler (game event &rest args) + (unless chess-engine-handling-event + (cond + ((eq event 'initialize) + (let ((proc (chess-common-handler game 'initialize "gnuchess"))) + (when (and (processp proc) + (eq (process-status proc) 'run)) + (process-send-string proc "nopost\n") + t))) - ((eq event 'setup-pos) - (let ((file (chess-with-temp-file - (insert (chess-pos-to-string (car args)) ?\n)))) - (chess-engine-send nil (format "epdload %s\n" file)))) + ((eq event 'setup-pos) + (let ((file (chess-with-temp-file + (insert (chess-pos-to-string (car args)) ?\n)))) + (chess-engine-send nil (format "epdload %s\n" file)))) - ((eq event 'setup-game) - (let ((file (chess-with-temp-file - (insert (chess-game-to-string (car args)) ?\n)))) - (chess-engine-send nil (format "pgnload %s\n" file)))) + ((eq event 'setup-game) + (let ((file (chess-with-temp-file + (insert (chess-game-to-string (car args)) ?\n)))) + (chess-engine-send nil (format "pgnload %s\n" file)))) - ((eq event 'pass) - (chess-engine-send nil (concat (if (chess-pos-side-to-move - (chess-engine-position nil)) - "white" "black") - "\n")) - (chess-engine-send nil "go\n") - (setq chess-gnuchess-bad-board nil)) - - ((eq event 'move) - (chess-engine-send nil (concat (chess-ply-to-algebraic (car args)) - "\n")) - (when chess-gnuchess-bad-board + ((eq event 'pass) + (chess-engine-send nil (concat (if (chess-pos-side-to-move + (chess-engine-position nil)) + "white" "black") + "\n")) (chess-engine-send nil "go\n") - (setq chess-gnuchess-bad-board nil))) + (setq chess-gnuchess-bad-board nil)) + + ((eq event 'move) + (chess-engine-send nil (concat (chess-ply-to-algebraic (car args)) + "\n")) + (when chess-gnuchess-bad-board + (chess-engine-send nil "go\n") + (setq chess-gnuchess-bad-board nil))) - (t - (apply 'chess-common-handler event args)))) + (t + (apply 'chess-common-handler game event args))))) (provide 'chess-gnuchess) |
