diff options
| -rw-r--r-- | PLAN | 9 | ||||
| -rw-r--r-- | chess-algebraic.el | 3 | ||||
| -rw-r--r-- | chess-display.el | 6 | ||||
| -rw-r--r-- | chess-game.el | 6 | ||||
| -rw-r--r-- | chess-ics.el | 16 | ||||
| -rw-r--r-- | chess-ply.el | 16 | ||||
| -rw-r--r-- | chess-pos.el | 6 |
7 files changed, 40 insertions, 22 deletions
@@ -8,19 +8,20 @@ chess-ply to the creating ply! - Thus there will be a mirror set of chess-pos-has-keyword, etc., functions +- Need to detect games drawn by three-fold repetition chess-display - there is no way to call flag right now +- invert the mode line to show the side on move? chess-ics - detect draw/resign/retract, etc. - add support for ICS observing chess-clock -- when a clock runs down, indicate this in the modeline, and allow the - user to call-flag in order to win on time; note: the user should be - allowed to try anyway, in case our clock has become out-of-sync with - the server's +- when a clock runs down, allow the user to call-flag in order to win + on time; note: the user should be allowed to try anyway, in case our + clock has become out-of-sync with the server's chess-images - in a generic emacs, with a light background, there are white lines diff --git a/chess-algebraic.el b/chess-algebraic.el index 95b5bc6..0ae8016 100644 --- a/chess-algebraic.el +++ b/chess-algebraic.el @@ -165,8 +165,7 @@ This regexp handles both long and short form.") (chess-index-to-coord to) (let ((promote (chess-ply-keyword ply :promote))) (if promote - (concat "=" (char-to-string - (upcase (cadr promote)))))) + (concat "=" (char-to-string promote)))) (if (chess-ply-keyword ply :check) "+" (if (chess-ply-keyword ply :checkmate) "#")))))) diff --git a/chess-display.el b/chess-display.el index 5e63f1e..625c2e8 100644 --- a/chess-display.el +++ b/chess-display.el @@ -256,7 +256,9 @@ also view the same game." (aset chess-display-index-positions pos-index pos)) (setq pos (next-single-property-change pos 'chess-coord))) (unless (aref chess-display-index-positions 0) - (aset chess-display-index-positions 0 (point-min))))) + (aset chess-display-index-positions 0 (point-min))) + (unless (aref chess-display-index-positions 63) + (aset chess-display-index-positions 63 (1- (point-max)))))) (aref chess-display-index-positions index))) (defun chess-display-paint-move (display ply) @@ -387,7 +389,7 @@ that is supported by most displays, and is the default mode." :group 'chess-display) (defcustom chess-display-momentous-events - '(orient post-undo setup-game pass move resign) + '(orient post-undo setup-game pass move resign drawn) "Events that will refresh, and cause 'main' displays to popup. These are displays for which `chess-display-set-main' has been called." diff --git a/chess-game.el b/chess-game.el index e5c93b7..970274e 100644 --- a/chess-game.el +++ b/chess-game.el @@ -250,8 +250,10 @@ progress (nil), if it is drawn, resigned, mate, etc." (assert changes) (chess-ply-set-changes current-ply changes) - (chess-game-add-ply game (chess-ply-create* - (chess-ply-next-pos current-ply))) + (unless (chess-ply-any-keyword ply :draw :perpetual :repetition + :resign) + (chess-game-add-ply game (chess-ply-create* + (chess-ply-next-pos current-ply)))) (let ((long (> (length changes) 2))) (cond diff --git a/chess-ics.el b/chess-ics.el index 1341ae1..4b9c896 100644 --- a/chess-ics.el +++ b/chess-ics.el @@ -83,6 +83,11 @@ The format of each entry is: (lambda () (let ((chess-engine-pending-offer 'my-undo)) (funcall chess-engine-response-handler 'accept))))) + (cons "\\(\\S-+\\) resigns}" + (function + (lambda () + (if (string= (match-string 1) chess-engine-opponent-name) + (funcall chess-engine-response-handler 'resign))))) (cons "Illegal move (\\([^)]+\\))\\." (function (lambda () @@ -258,6 +263,10 @@ who is black." (chess-game-set-data game 'my-color (if (= 1 (nth 6 info)) color (not color))) + (setq chess-engine-opponent-name + (if (= 1 (nth 6 info)) + (nth 3 info) + (nth 2 info))) (chess-game-set-data game 'active t) (chess-game-set-data game 'white-remaining (nth 4 info)) (chess-game-set-data game 'black-remaining (nth 5 info))) @@ -274,6 +283,11 @@ who is black." (buffer-substring-no-properties begin end))) (goto-char begin) (delete-region begin end) + (save-excursion + (while (and (forward-line -1) + (or (looking-at "^[ \t]*$") + (looking-at "^[^% \t\n\r]+%\\s-*$"))) + (delete-region (match-beginning 0) (1+ (match-end 0))))) ;; we need to counter the forward-line in chess-engine-filter (unless error (forward-line -1))) @@ -333,6 +347,8 @@ who is black." (comint-send-string (get-buffer-process (current-buffer)) (car args))) + ((eq event 'set-index)) + (t (apply 'chess-network-handler game event args))))) diff --git a/chess-ply.el b/chess-ply.el index 750e8b2..b21c21f 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -191,16 +191,12 @@ maneuver." ;; is this a pawn move to the ultimate rank? if so, and ;; we haven't already been told, ask for the piece to ;; promote it to - (if (and (not (memq :promote changes)) - (= (if color 0 7) (chess-index-rank (cadr changes)))) - (let ((new-piece (completing-read - (chess-string 'pawn-promote-query) - chess-piece-name-table nil t "queen"))) - (setq new-piece - (cdr (assoc new-piece chess-piece-name-table))) - (if color - (setq new-piece (upcase new-piece))) - (nconc changes (list :promote new-piece)))) + (when (and (not (memq :promote changes)) + (= (if color 0 7) (chess-index-rank (cadr changes)))) + (discard-input) + (let ((new-piece (if (yes-or-no-p "Promote to queen? ") + ?Q ?N))) + (nconc changes (list :promote (upcase new-piece))))) ;; is this an en-passant capture? (if (= (or (chess-pos-en-passant position) 100) diff --git a/chess-pos.el b/chess-pos.el index 79a92da..d0b6dd5 100644 --- a/chess-pos.el +++ b/chess-pos.el @@ -530,7 +530,8 @@ indices which indicate where a piece may have moved from." '(?P ?R ?N ?B ?Q ?K))) (mapc 'chess--add-candidate (chess-search-position position target - (if piece p (downcase p)))))) + (if piece p (downcase p)) + check-only)))) ;; skip erroneous space requests ((= test-piece ? )) @@ -631,7 +632,8 @@ indices which indicate where a piece may have moved from." (while (and legal (funcall (if long '< '>) file king-file)) (setq pos (chess-rf-to-index rank file)) (if (or (not (chess-pos-piece-p position pos ? )) - (chess-search-position position pos (not color))) + (chess-search-position position pos (not color) + check-only)) (setq legal nil) (setq file (funcall (if long '1+ '1-) file)))) (if legal |
