]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/gnugo/gnugo.el
[gnugo] Fix bug: DTRT for :last-user-bpos in undo-one-move ME-NEXT.
[gnu-emacs-elpa] / packages / gnugo / gnugo.el
index 256998bb589b26ac5ee85aff8a88113e516ff7c2..76e67d20726304042e324c521d1b69729e375a67 100644 (file)
@@ -2017,13 +2017,13 @@ move was done by the color you prefer to play:
 See also `gnugo-undo-two-moves'."
   (interactive "P")
   (gnugo-gate)
-  (gnugo-magic-undo 1 t)
   (when me-next
-    (let* ((wait (gnugo-get :last-mover))
-           (play (gnugo-other wait)))
+    (let* ((play (gnugo-get :last-mover))
+           (wait (gnugo-other play)))
       (gnugo--who-is-who wait play (string= play (gnugo-get :user-color)))
       (gnugo-put :user-color play)
-      (gnugo-put :gnugo-color wait))))
+      (gnugo-put :gnugo-color wait)))
+  (gnugo-magic-undo 1 t))
 
 (defun gnugo-undo-two-moves ()
   "Undo a pair of moves (GNU Go's and yours).
@@ -2550,13 +2550,15 @@ See `gnugo-board-mode' for a full list of commands."
       (let ((g (gnugo-get :gnugo-color))
             (n (or (gnugo--root-prop :HA) 0))
             (u (gnugo-get :user-color)))
-        (gnugo-put :last-mover
-          (if (or (and (gnugo--blackp u) (< 1 n))
-                  (and (gnugo--blackp g) (< n 2)))
-              u
-            g))
+        (unless (gnugo-get :last-mover)
+          (gnugo-put :last-mover
+            (if (or (and (gnugo--blackp u) (< 1 n))
+                    (and (gnugo--blackp g) (< n 2)))
+                u
+              g)))
         (run-hooks 'gnugo-start-game-hook)
-        (when (string= g (gnugo-current-player))
+        (when (and (not (gnugo-get :game-over))
+                   (string= g (gnugo-current-player)))
           (gnugo-refresh t)
           (gnugo-get-move g))))))