summaryrefslogtreecommitdiff
path: root/chess-network.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-09 04:26:02 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-09 04:26:02 +0000
commit6b8ac5acf330b03e88d0b342c79abbb7d338e0c2 (patch)
tree9df6dc3602f81a1acd5f2d6d234b6e4f6a45d57f /chess-network.el
parent18f22844af74b15732d7fc7dfad318a1ba0c0d99 (diff)
Bug fixes and the beginnings of ICS client support
Diffstat (limited to 'chess-network.el')
-rw-r--r--chess-network.el29
1 files changed, 14 insertions, 15 deletions
diff --git a/chess-network.el b/chess-network.el
index af833ee..af22f92 100644
--- a/chess-network.el
+++ b/chess-network.el
@@ -8,11 +8,12 @@
(require 'chess-fen)
(require 'chess-algebraic)
-(defvar chess-network-now-moving nil)
-
(defvar chess-network-regexp-alist
(list (cons chess-algebraic-regexp
- 'chess-network-perform-move)
+ (function
+ (lambda ()
+ (funcall chess-engine-response-handler 'move
+ (match-string 0)))))
(cons "pass"
(function
(lambda ()
@@ -30,15 +31,11 @@
(cons "quit"
(function
(lambda ()
- (funcall chess-engine-response-handler 'quit))))))
-
-(defun chess-network-perform-move ()
- (let* ((move (match-string 1))
- (ply (chess-algebraic-to-ply (chess-engine-position nil) move)))
- (if ply
- (let ((chess-network-now-moving t))
- (funcall chess-engine-response-handler 'move ply))
- (message "Received invalid move: %s" move))))
+ (funcall chess-engine-response-handler 'quit))))
+ (cons "resign"
+ (function
+ (lambda ()
+ (funcall chess-engine-response-handler 'resign))))))
(defun chess-network-handler (event &rest args)
"Initialize the network chess engine."
@@ -71,10 +68,12 @@
((eq event 'pass)
(chess-engine-send nil "pass\n"))
+ ((eq event 'resign)
+ (chess-engine-send nil "resign\n"))
+
((eq event 'move)
- (unless chess-network-now-moving
- (chess-engine-send nil (concat (chess-ply-to-algebraic (car args))
- "\n"))))))
+ (chess-engine-send nil (concat (chess-ply-to-algebraic (car args))
+ "\n")))))
(provide 'chess-network)