summaryrefslogtreecommitdiff
path: root/chess-announce.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-05-01 07:45:36 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-05-01 07:45:36 +0000
commit3d3bbb7d7de849b139e612ad069a530c8ef9c342 (patch)
tree73ddb051dd9b0f1f5bdc524ed243d6d903d6d97c /chess-announce.el
parentb605ecc7086e872fb57d340427e603674cb5a4b3 (diff)
Announce pawn promotions
Diffstat (limited to 'chess-announce.el')
-rw-r--r--chess-announce.el23
1 files changed, 14 insertions, 9 deletions
diff --git a/chess-announce.el b/chess-announce.el
index e4031b8..a607543 100644
--- a/chess-announce.el
+++ b/chess-announce.el
@@ -18,6 +18,7 @@
(checkmate . "checkmate")
(stalemate . "stalemate")
(en-passant . "on possont")
+ (promote . "promote to %s")
(piece-moves . "%s to %s")
(piece-takes . "%s takes %s at %s")))
@@ -44,6 +45,10 @@ The first is called one start of the announcer. The second is called
with the string to announce each time. The third is called to
shutdown the announcer process, if necessary.")
+(defsubst chess-piece-name (char)
+ (chess-string (cdr (assq (downcase char)
+ chess-announce-names))))
+
(defun chess-announce-handler (game event &rest args)
(cond
((eq event 'initialize)
@@ -75,22 +80,22 @@ shutdown the announcer process, if necessary.")
(setq text
(concat which
(chess-string 'piece-moves
- (chess-string
- (cdr (assq (downcase s-piece)
- chess-announce-names)))
+ (chess-piece-name s-piece)
(chess-index-to-coord target)))))
((and s-piece t-piece target)
(setq text
(concat which
(chess-string 'piece-takes
- (chess-string
- (cdr (assq (downcase s-piece)
- chess-announce-names)))
- (chess-string
- (cdr (assq (downcase t-piece)
- chess-announce-names)))
+ (chess-piece-name s-piece)
+ (chess-piece-name t-piece)
(chess-index-to-coord target))))))
+ (let ((promotion (chess-ply-keyword ply :promote)))
+ (if promotion
+ (setq text
+ (concat text ", "
+ (chess-string 'promote
+ (chess-piece-name promotion))))))
(if (chess-ply-keyword ply :en-passant)
(setq text (concat text ", " (chess-string 'en-passant))))
(if (chess-ply-keyword ply :check)