summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-05-01 23:15:00 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-05-01 23:15:00 +0000
commitf43a2ebec00d93a8898715cd73bec03f277744e9 (patch)
treec9e27d2fa6c8c1406ab05c016bd2ad8252f56585
parent3169a8123361adb22387572b0c4647ce32c1917c (diff)
added code for forfeiting on time
-rw-r--r--PLAN2
-rw-r--r--chess-common.el5
-rw-r--r--chess-engine.el9
-rw-r--r--chess-ics.el5
-rw-r--r--chess-network.el8
5 files changed, 27 insertions, 2 deletions
diff --git a/PLAN b/PLAN
index c3a3fcb..99e9921 100644
--- 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
diff --git a/chess-common.el b/chess-common.el
index 462050f..ce320b4 100644
--- a/chess-common.el
+++ b/chess-common.el
@@ -83,6 +83,11 @@
(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)
diff --git a/chess-engine.el b/chess-engine.el
index f50038d..360ed19 100644
--- a/chess-engine.el
+++ b/chess-engine.el
@@ -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)
@@ -269,8 +270,12 @@
'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))
diff --git a/chess-ics.el b/chess-ics.el
index 020fa44..9d5c9bb 100644
--- a/chess-ics.el
+++ b/chess-ics.el
@@ -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 ()
diff --git a/chess-network.el b/chess-network.el
index f4a369b..e78eabc 100644
--- a/chess-network.el
+++ b/chess-network.el
@@ -74,6 +74,10 @@
(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 ()
@@ -195,6 +199,10 @@
((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)))))