[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 233/255: igs handle adjourned and resigned games
From: |
Eric Schulte |
Subject: |
[elpa] 233/255: igs handle adjourned and resigned games |
Date: |
Sun, 16 Mar 2014 01:02:54 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 5f33c9fb1d66c8db94d209ec44265ff3d014554f
Author: Eric Schulte <address@hidden>
Date: Thu Aug 8 14:31:33 2013 -0600
igs handle adjourned and resigned games
---
back-ends/igs.el | 38 ++++++++++++++++++++++++++++++++++----
1 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/back-ends/igs.el b/back-ends/igs.el
index 5da6c62..81225d3 100644
--- a/back-ends/igs.el
+++ b/back-ends/igs.el
@@ -142,8 +142,18 @@ This is used to re-send messages to keep the IGS server
from timing out.")
("^games" (igs-list-games *igs-instance* *igs-games*))
(t nil))
(setq *igs-last-command* nil))
- (:info (unless (string= content "yes")
- (message "igs-info: %s" content)))
+ (:info
+ (igs-re-cond content
+ ;; Game NN: name1 vs name2 has adjourned.
+ ("^Game \\([0-9]*\\): .*adjourned.$"
+ (igs-handle-adjournment (match-string 1 content)))
+ ;; {Game NN: name1 vs name2 : color resigns.}
+ ("^{Game \\([0-9]*\\): \\(Black\\|White\\) resigns.}$"
+ (igs-handle-resignation (igs-re-cond (match-string 2 content)
+ ("black" :black)
+ ("white" :white))))
+ (t (unless (string= content "yes")
+ (message "igs-info: %s" content)))))
(:games (igs-w-proc proc (igs-handle-game content)))
(:move (igs-w-proc proc (igs-handle-move content)))
(:kibitz (message "igs-kibitz: %s" content))
@@ -300,6 +310,24 @@ This is used to re-send messages to keep the IGS server
from timing out.")
(set-buffer (get-buffer "*igs-game-list*"))
(list-buffer-refresh))))))
+(defun igs-handle-adjournment (number-string)
+ (if (aget (igs-current-game) :board)
+ (with-current-buffer (buffer (aget (igs-current-game) :board))
+ (with-backends backend
+ (when (equal (class-of backend) 'igs)
+ (setf (active backend) nil))))
+ (error "igs-handle-adjournment: no board!")))
+
+(defun igs-handle-resignation (color)
+ (if (aget (igs-current-game) :board)
+ (progn
+ (go-resign (aget (igs-current-game) :board))
+ (with-current-buffer (buffer (aget (igs-current-game) :board))
+ (with-backends backend
+ (when (equal (class-of backend) 'igs)
+ (setf (active backend) nil)))))
+ (error "igs-handle-adjournment: no board!")))
+
(defun igs-to-pos (color igs)
(cons (make-keyword color)
(cons :pos
@@ -396,7 +424,8 @@ This is used to re-send messages to keep the IGS server
from timing out.")
(defclass igs ()
((buffer :initarg :buffer :accessor buffer :initform nil)
;; number of an observed IGS game
- (number :initarg :number :accessor number :initform nil)))
+ (number :initarg :number :accessor number :initform nil)
+ (active :initarg :active :accessor active :initform t)))
(defmethod go-connect ((igs igs)) (igs-connect igs))
@@ -491,7 +520,8 @@ This is used to re-send messages to keep the IGS server
from timing out.")
(progn
;; TOOD: ensure still on our server-side observation list
;; (e.g., hasn't been removed after a resignation)
- (igs-send (format "observe %d" (number igs)))
+ (when (active igs)
+ (igs-send (format "observe %d" (number igs))))
(setf (number igs) nil))
(igs-send "quit"))))
- [elpa] 243/255: undo through gtp pipe, (continued)
- [elpa] 243/255: undo through gtp pipe, Eric Schulte, 2014/03/15
- [elpa] 246/255: customizable default gnugo options, Eric Schulte, 2014/03/15
- [elpa] 241/255: igs class definitions up front for better loading, Eric Schulte, 2014/03/15
- [elpa] 247/255: notes, Eric Schulte, 2014/03/15
- [elpa] 235/255: better line truncation, Eric Schulte, 2014/03/15
- [elpa] 250/255: mark dead stones at end of game, Eric Schulte, 2014/03/15
- [elpa] 229/255: igs TODO: consistent game un-observation, Eric Schulte, 2014/03/15
- [elpa] 242/255: need assoc for aget, Eric Schulte, 2014/03/15
- [elpa] 228/255: refresh the game list buffer, Eric Schulte, 2014/03/15
- [elpa] 211/255: scale column width by buffer width, Eric Schulte, 2014/03/15
- [elpa] 233/255: igs handle adjourned and resigned games,
Eric Schulte <=
- [elpa] 244/255: igs-pipe handles resignation and comments, Eric Schulte, 2014/03/15
- [elpa] 245/255: misc fixes, Eric Schulte, 2014/03/15
- [elpa] 169/255: igs: automatically collect a game listing, Eric Schulte, 2014/03/15
- [elpa] 248/255: try to fix gnugo Emacs crashes, Eric Schulte, 2014/03/15
- [elpa] 254/255: re-format README, Eric Schulte, 2014/03/15
- [elpa] 161/255: moving towards using images, Eric Schulte, 2014/03/15
- [elpa] 240/255: robust loading w/o load-path customization, Eric Schulte, 2014/03/15
- [elpa] 253/255: renamed el-go README, Eric Schulte, 2014/03/15
- [elpa] 227/255: TODO retain comments, Eric Schulte, 2014/03/15
- [elpa] 231/255: refresh message, Eric Schulte, 2014/03/15