From 91a1e2d52130c9e6f90497614633c7f4e1efb5b3 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 9 Apr 2002 10:06:44 +0000 Subject: *** no comment *** --- chess-engine.el | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'chess-engine.el') diff --git a/chess-engine.el b/chess-engine.el index fd448fe..23622ed 100644 --- a/chess-engine.el +++ b/chess-engine.el @@ -62,29 +62,26 @@ (let ((chess-engine-handling-event t)) (cond ((eq event 'move) - - ;; if the game index is still 0, then our opponent is white, and - ;; we need to pass over the move - (let ((game (chess-engine-game nil))) - (when (and game (chess-game-get-data game 'my-color) - (= (chess-game-index game) 0)) - (chess-game-run-hooks game 'pass) - ;; if no one else flipped my-color, we'll do it - (if (chess-game-get-data game 'my-color) - (chess-game-set-data game 'my-color nil)))) - (let ((ply (chess-algebraic-to-ply (chess-engine-position nil) (car args)))) - (if ply - (chess-engine-do-move ply) - (message "Received invalid move from engine: %s" (car args))))) + (if (null ply) + (message "Received invalid move from engine: %s" (car args)) + ;; if the game index is still 0, then our opponent is white, + ;; and we need to pass over the move + (let ((game (chess-engine-game nil))) + (when (and game (chess-game-get-data game 'my-color) + (= (chess-game-index game) 0)) + (chess-game-run-hooks game 'pass) + ;; if no one else flipped my-color, we'll do it + (if (chess-game-get-data game 'my-color) + (chess-game-set-data game 'my-color nil)))) + (chess-engine-do-move ply)))) ((eq event 'pass) (message "Your opponent has passed the first move to you")) ((eq event 'connect) - (message "Your opponent, %s, is now ready to play" (car args)) - (chess-engine-send nil (format "name %s\n" (user-full-name)))) + (message "Your opponent, %s, is now ready to play" (car args))) ((eq event 'quit) (message "Your opponent has quit playing")) -- cgit v1.2.3