diff options
| author | John Wiegley <johnw@newartisans.com> | 2008-09-01 03:46:41 -0400 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2008-09-01 05:05:16 -0400 |
| commit | e02e36b9e62af44091cdf98c1ab4e153b5d55c82 (patch) | |
| tree | 20614434849ff1d753d930d0f3ba041e9340e46e | |
| parent | 2d588570a4a77246c33d025f8851c6c3ce2202b8 (diff) | |
Report a clearer error in the case of an algebraic queening move with an
unspecified promotion.
| -rw-r--r-- | chess-algebraic.el | 10 | ||||
| -rw-r--r-- | chess-ply.el | 23 |
2 files changed, 20 insertions, 13 deletions
diff --git a/chess-algebraic.el b/chess-algebraic.el index 89ca0a6..af2f898 100644 --- a/chess-algebraic.el +++ b/chess-algebraic.el @@ -120,11 +120,17 @@ This regexp handles both long and short form.") (when changes (when trust (if mate - (nconc changes (list (if (equal mate "#") :checkmate :check))))) + (nconc changes (list (if (equal mate "#") + :checkmate + :check))))) (unless long-style (nconc changes (list :san move))) - (apply 'chess-ply-create position trust changes)))))) + (condition-case err + (apply 'chess-ply-create position trust changes) + (error + (error "Error in algebraic move '%s': %s" + move (error-message-string err))))))))) (defun chess-ply--move-text (ply long) (or 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? |
