diff options
| -rw-r--r-- | chess-ply.el | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/chess-ply.el b/chess-ply.el index dfae21f..66df7f3 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -177,26 +177,21 @@ (list position)) -(defvar promotion-options - '(queen rook bishop knight)) +(defconst promotion-options + '((queen ?Q ?q) + (rook ?R ?r) + (bishop ?B ?b) + (knight ?N ?n))) (defun ask-promotion (white) - (let ((p (ido-completing-read "Symbol? " (mapcar #'symbol-name promotion-options)))) - (cond ((string= "queen" p) - (if white ?Q ?q)) - - ((string= "rook" p) - (if white ?R ?r)) - - ((string= "bishop" p) - (if white ?B ?b)) - - ((string= "knight" p) - (if white ?N ?n)) - - ;; Promote to queen as fallback - (t (if white ?Q ?q))))) - + (nth (if white 1 2) + (assoc (intern-soft + (or (completing-read + "Symbol? " + (mapcar (lambda (x) (symbol-name (car x))) + promotion-options)) + "queen")) + promotion-options))) (defun chess-ply-create (position &optional valid-p &rest changes) "Create a ply from the given POSITION by applying the supplied CHANGES. @@ -246,9 +241,7 @@ maneuver." (= (if color 0 7) (chess-index-rank (cadr changes)))) (let ((promo (ask-promotion color))) - (setq changes - (append changes (list :promote promo))) - + (nconc changes (list :promote promo)) (setq ply (cons position changes)))) ;; is this an en-passant capture? |
