diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-09 10:06:44 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-09 10:06:44 +0000 |
| commit | 91a1e2d52130c9e6f90497614633c7f4e1efb5b3 (patch) | |
| tree | 38931f48bf619024784db4a1cdfa56eb630af26f /chess-engine.el | |
| parent | 4a5de0c46970e59b1cb890cdb6cdfdcae47b34a8 (diff) | |
*** no comment ***
Diffstat (limited to 'chess-engine.el')
| -rw-r--r-- | chess-engine.el | 29 |
1 files changed, 13 insertions, 16 deletions
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")) |
