emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 01/04: [gnugo] Add abstraction: gnugo-current-player


From: Thien-Thi Nguyen
Subject: [elpa] 01/04: [gnugo] Add abstraction: gnugo-current-player
Date: Wed, 16 Apr 2014 15:44:35 +0000

ttn pushed a commit to branch master
in repository elpa.

commit bc4275c6054aa90ad846f100cb37415bd6fcacc2
Author: Thien-Thi Nguyen <address@hidden>
Date:   Wed Apr 16 11:48:18 2014 +0200

    [gnugo] Add abstraction: gnugo-current-player
    
    * packages/gnugo/gnugo.el (gnugo-current-player): New func.
    (gnugo-refresh, gnugo-magic-undo, gnugo): Use it.
---
 packages/gnugo/NEWS     |    1 +
 packages/gnugo/gnugo.el |   16 +++++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/packages/gnugo/NEWS b/packages/gnugo/NEWS
index 3c51bdf..98ee291 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/NEWS
@@ -36,6 +36,7 @@ NB: "RCS: X..Y " means that the particular release includes
     - ‘:sgf-gametree’ internal representation inverted (BI)
     - ‘gnugo-magic-undo’ handles SPEC ‘0’
     - dropped ‘(gnugo-move-history 'count)’ (BI)
+    - new func: ‘gnugo-current-player’
 
 - 2.3.1 | 2014-02-27
   - portability fixes
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 7e7f446..59db6dd 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -332,6 +332,10 @@ Handle the big, slow-to-render, and/or uninteresting ones 
specially."
 (defun gnugo-other (color)
   (if (gnugo--blackp color) "white" "black"))
 
+(defun gnugo-current-player ()
+  "Return the current player, either \"black\" or \"white\"."
+  (gnugo-other (gnugo-get :last-mover)))
+
 (defsubst gnugo--gate-game-over (enable)
   (when (and enable (gnugo-get :game-over))
     (user-error "Sorry, game over")))
@@ -1545,7 +1549,7 @@ its move."
                         ,(case c
                            (?b '(or (gnugo-get :black-captures) 0))
                            (?w '(or (gnugo-get :white-captures) 0))
-                           (?p '(gnugo-other (gnugo-get :last-mover)))
+                           (?p '(gnugo-current-player))
                            (?t '(let ((ws (gnugo-get :waiting-start)))
                                   (if ws
                                       (cadr (time-since ws))
@@ -1957,7 +1961,7 @@ when play resumes."
       (unless (= ?= (aref ans 0))
         (user-error "%s" ans))
       (pop (aref monkey 0))
-      (gnugo-put :last-mover (gnugo-other (gnugo-get :last-mover)))
+      (gnugo-put :last-mover (gnugo-current-player))
       (gnugo-merge-showboard-results)   ; all
       (gnugo-refresh)                   ; this
       (decf n)                          ; is
@@ -2546,10 +2550,12 @@ starting a new one.  See `gnugo-board-mode' 
documentation for more info."
       (let ((g (gnugo-get :gnugo-color))
             (n (or (gnugo--root-prop :HA) 0))
             (u (gnugo-get :user-color)))
-        (gnugo-put :last-mover g)
-        (when (or (and (gnugo--blackp u) (< 1 n))
+        (gnugo-put :last-mover
+          (if (or (and (gnugo--blackp u) (< 1 n))
                   (and (gnugo--blackp g) (< n 2)))
-          (gnugo-put :last-mover u)
+              u
+            g))
+        (when (string= g (gnugo-current-player))
           (gnugo-refresh t)
           (gnugo-get-move g))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]