]> code.delx.au - gnu-emacs-elpa/commitdiff
added code for forfeiting on time
authorJohn Wiegley <johnw@newartisans.com>
Wed, 1 May 2002 23:15:00 +0000 (23:15 +0000)
committerJohn Wiegley <johnw@newartisans.com>
Wed, 1 May 2002 23:15:00 +0000 (23:15 +0000)
PLAN
chess-common.el
chess-engine.el
chess-ics.el
chess-network.el

diff --git a/PLAN b/PLAN
index c3a3fcb068e89ce5bc5890334c81c74fef97b658..99e99215fa5c66e7a4f45321e14d070ce9c86dba 100644 (file)
--- a/PLAN
+++ b/PLAN
@@ -1,5 +1,7 @@
 chess-ics
 - finish all elements of regular use as a client
+- takebacks still aren't working 100%
+- display a notice in the minibuffer when a takeback request is sent
 
 chess-ply
 - detect games drawn by three-fold repetition
index 462050f31d385f8df7d146edb8d08e420b52ee47..ce320b44f979e3a7c314e33dcca34bb297085a4c 100644 (file)
     (let ((chess-engine-handling-event t))
       (chess-game-undo game (car args))))
 
+   ((eq event 'flag-fell)
+    (chess-game-set-data game 'active nil)
+    (let ((chess-game-inhibit-events t))
+      (chess-game-end game :flag-fell)))
+
    ((eq event 'move)
     (when (= 1 (chess-game-index game))
       (chess-game-set-tag game "White" chess-full-name)
index f50038df4c016c33fdf2bff90aacf643e8b2f482..360ed19efc214597ad166e5889c92ac59c82106d 100644 (file)
@@ -68,6 +68,7 @@
     (opp-undo-ret   . "Your opponent has retracted their request to undo %d moves")
     (opp-illegal    . "Your opponent states your last command was illegal")
     (opp-call-flag  . "Your flag fell, and your opponent has called time")
+    (opp-flag-fell  . "Your opponent has forfeited the game on time")
     (failed-start   . "Failed to start chess engine process")))
 
 (defsubst chess-engine-convert-algebraic (move &optional trust-check)
                                     'black-remaining))))
        (when (< remaining 0)
          (chess-message 'opp-call-flag)
-         (chess-game-end game :flag-fell)
-         (chess-game-set-data game 'active nil))))
+         (chess-game-run-hooks game 'flag-fell))))
+
+     ((eq event 'flag-fell)
+      (chess-message 'opp-flag-fell)
+      (chess-game-end game :flag-fell)
+      (chess-game-set-data game 'active nil))
 
      ((eq event 'kibitz)
       (let ((chess-engine-handling-event t))
index 020fa447124a0452f8805239ae7f56203d2aef5b..9d5c9bbb51d1c7b6ad629c7ed90dff41873ef7ae 100644 (file)
@@ -88,6 +88,11 @@ The format of each entry is:
               (lambda ()
                 (if (string= (match-string 1) chess-engine-opponent-name)
                     (funcall chess-engine-response-handler 'resign)))))
+       (cons "\\(\\S-+\\) forfeits on time}"
+             (function
+              (lambda ()
+                (if (string= (match-string 1) chess-engine-opponent-name)
+                    (funcall chess-engine-response-handler 'flag-fell)))))
        (cons "Illegal move (\\([^)]+\\))\\."
              (function
               (lambda ()
index f4a369b9ae06c0725e902679efe906e1488dd195..e78eabcee07863712545aa6021c4dcebcd73a70a 100644 (file)
         (function
          (lambda ()
            (funcall chess-engine-response-handler 'call-flag))))
+   (cons "forfeit$"
+        (function
+         (lambda ()
+           (funcall chess-engine-response-handler 'flag-fell))))
    (cons "kibitz\\s-+\\(.+\\)$"
         (function
          (lambda ()
      ((eq event 'set-index)
       (chess-engine-send nil (format "index %d\n" (car args))))
 
+     ((eq event 'flag-fell)
+      (chess-engine-send nil "forfeit\n")
+      (chess-common-handler game 'flag-fell))
+
      (t
       (apply 'chess-common-handler game event args)))))