diff options
| -rw-r--r-- | TODO | 6 | ||||
| -rw-r--r-- | chess-engine.el | 29 | ||||
| -rw-r--r-- | chess-game.el | 2 | ||||
| -rw-r--r-- | chess-irc.el | 4 |
4 files changed, 22 insertions, 19 deletions
@@ -7,6 +7,12 @@ analysis/highlight tools scid interaction +- Make use of the my-color data in chess-game.el to ensure that I only + do what I should be doing + +- After somebody sends me "name", I need a responding event to tell + them my name + - Allow the user to request a move retraction (ala takeback) - In edit mode, mouse-2 and mouse-3 should provide a drop-down list of 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")) diff --git a/chess-game.el b/chess-game.el index 6e22ff8..500df8d 100644 --- a/chess-game.el +++ b/chess-game.el @@ -88,7 +88,7 @@ (defun chess-game-set-data (game key value) (let ((alist (chess-game-data-alist game))) (if (null alist) - (setcar (nthcdr 1 game) (list (cons key value))) + (setcar (nthcdr 2 game) (list (cons key value))) (push (cons key value) alist)) (chess-game-run-hooks game 'set-data key))) diff --git a/chess-irc.el b/chess-irc.el index d1fe256..78e49a4 100644 --- a/chess-irc.el +++ b/chess-irc.el @@ -65,13 +65,13 @@ (set-process-filter proc 'chess-irc-filter) (set-process-buffer proc (current-buffer)) (set-marker (process-mark proc) (point)) - (message "Now waiting for 'name USER' via /msg; or `M-x chess-irc-engage'"))) + (message "Now waiting for 'name USER' via /msg, or `M-x chess-irc-engage'"))) (setq chess-irc-process proc)) nil) ((eq event 'shutdown) (ignore-errors - (chess-engine-send nil "game over")) + (chess-engine-send nil "quit")) (ignore-errors (process-send-string chess-irc-process "QUIT :Goodbye\n")) (ignore-errors |
