[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 01/02: * chess-algebraic.el (chess-ply-to-algebraic): If TYPE is
From: |
Mario Lang |
Subject: |
[elpa] 01/02: * chess-algebraic.el (chess-ply-to-algebraic): If TYPE is `:numeric', generate ICCF numeric notation. |
Date: |
Sat, 14 Jun 2014 11:32:44 +0000 |
mlang pushed a commit to branch externals/chess
in repository elpa.
commit d26ae3b157f0374e43cef34f798d633107d456d8
Author: Mario Lang <address@hidden>
Date: Sat Jun 14 12:12:20 2014 +0200
* chess-algebraic.el (chess-ply-to-algebraic): If TYPE is `:numeric',
generate ICCF numeric notation.
---
ChangeLog | 5 +++++
chess-algebraic.el | 19 +++++++++++++++----
chess-polyglot.el | 4 +---
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1a073c7..2ae3d04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-14 Mario Lang <address@hidden>
+
+ * chess-algebraic.el (chess-ply-to-algebraic): If TYPE is `:numeric',
+ generate ICCF numeric notation.
+
2014-06-13 Mario Lang <address@hidden>
* chess-pos.el (chess-pos-en-passant, chess-pos-status)
diff --git a/chess-algebraic.el b/chess-algebraic.el
index 49a95d6..13ae97b 100644
--- a/chess-algebraic.el
+++ b/chess-algebraic.el
@@ -165,17 +165,28 @@ Figurine notation is currently not supported."
(defun chess-ply-to-algebraic (ply &optional type)
"Convert the given PLY to algebraic notation.
Optional argument TYPE specifies the kind of algebraic notation to generate.
-`:san' (the default) generates short (or standard) algebraic notation.
-`:lan' generates long algebraic notation (like \"Nb1-c3\".
-`:fan' generates figurine algebraic notation (like \"♘c3\"."
+`:san' (the default) generates short (or standard) algebraic notation
+\(like \"Nc3\"). `:lan' generates long algebraic notation (like \"Nb1-c3\".
+`:fan' generates figurine algebraic notation (like \"♘c3\".
+Finally, `:numeric' generates ICCF numeric notation (like \"2133\"."
(cl-check-type ply (and list (not null)))
- (cl-check-type type (member nil :san :fan :lan))
+ (cl-check-type type (member nil :san :fan :lan :numeric))
(unless type (setq type :san))
(or (chess-ply-keyword ply type)
(and (null (chess-ply-source ply)) "")
(chess-ply-set-keyword
ply type
(or
+ (and (eq type :numeric)
+ (apply
+ #'string
+ (+ (chess-index-file (chess-ply-source ply)) ?1)
+ (+ (chess-index-rank (logxor (chess-ply-source ply) #o70)) ?1)
+ (+ (chess-index-file (chess-ply-target ply)) ?1)
+ (+ (chess-index-rank (logxor (chess-ply-target ply) #o70)) ?1)
+ (when (chess-ply-keyword ply :promote)
+ (list (+ (cl-position (chess-ply-keyword ply :promote)
+ '(?Q ?R ?B ?N)) ?1)))))
(and (chess-ply-keyword ply :castle) "O-O")
(and (chess-ply-keyword ply :long-castle) "O-O-O")
(let* ((pos (chess-ply-pos ply))
diff --git a/chess-polyglot.el b/chess-polyglot.el
index 717e1c4..96a918c 100644
--- a/chess-polyglot.el
+++ b/chess-polyglot.el
@@ -135,9 +135,7 @@ On reaching end or beginning of buffer, stop and signal
error."
"Non-nil if the polyglot key LHS is less than or equal to RHS."
(while (and lhs rhs (= (car lhs) (car rhs)))
(setq lhs (cdr lhs) rhs (cdr rhs)))
- (if (and (null lhs) (null rhs))
- t
- (<= (car lhs) (car rhs))))
+ (or (and (null lhs) (null rhs)) (<= (car lhs) (car rhs))))
(defun chess-polyglot-read-moves (key)
"Read all moves associated with KEY from the current buffer."