summaryrefslogtreecommitdiff
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
parentb605ecc7086e872fb57d340427e603674cb5a4b3 (diff)
Announce pawn promotions
-rw-r--r--chess-announce.el23
-rw-r--r--chess-sound.el4
2 files changed, 18 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)
diff --git a/chess-sound.el b/chess-sound.el
index 4a34121..b6c9669 100644
--- a/chess-sound.el
+++ b/chess-sound.el
@@ -90,6 +90,10 @@
(chess-sound (format "%c_" (downcase t-piece)))
(chess-sound (chess-index-to-coord target))))
+ (if (chess-ply-keyword ply :promote)
+ (chess-sound
+ (format "%c_" (downcase
+ (chess-ply-keyword ply :promote)))))
(if (chess-ply-keyword ply :en-passant)
(chess-sound "enpassant"))
(if (chess-ply-keyword ply :check)