From e02e36b9e62af44091cdf98c1ab4e153b5d55c82 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 1 Sep 2008 03:46:41 -0400 Subject: Report a clearer error in the case of an algebraic queening move with an unspecified promotion. --- chess-ply.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'chess-ply.el') diff --git a/chess-ply.el b/chess-ply.el index f4c943c..165e9f5 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -160,7 +160,8 @@ (if long :long-castle :castle)))))) (chess-message-catalog 'english - '((pawn-promote-query . "Promote to queen? "))) + '((pawn-promote-query . "Promote to queen? ") + (ambiguous-promotion . "Promotion event without :promote keyword"))) (defvar chess-ply-checking-mate nil) (defvar chess-ply-allow-interactive-query nil) @@ -215,16 +216,16 @@ maneuver." ;; we haven't already been told, ask for the piece to ;; promote it to (when (and (not (memq :promote changes)) - (= (if color 0 7) (chess-index-rank (cadr changes)))) - ;; jww (2002-05-15): This does not always clear ALL - ;; input events - (discard-input) (sit-for 0) (discard-input) - (let ((new-piece - (if chess-ply-allow-interactive-query - (if (yes-or-no-p - (chess-string 'pawn-promote-query)) - ?Q ?N) - (error "Promotion event without :promote keyword")))) + (= (if color 0 7) + (chess-index-rank (cadr changes)))) + ;; This does not always clear ALL input events + (discard-input) (sit-for 0) (sleep-for 0 1) + (discard-input) + (unless chess-ply-allow-interactive-query + (chess-error 'ambiguous-promotion)) + (let ((new-piece (if (yes-or-no-p + (chess-string 'pawn-promote-query)) + ?Q ?N))) (nconc changes (list :promote (upcase new-piece))))) ;; is this an en-passant capture? -- cgit v1.2.3