[LIB-9] Add SAN, NAG, move number and result PGN tokens
[chesshog.git] / chesshog-format / src / main / java / org / hedgecode / chess / pgn / format / ExportMovesFormat.java
index 4de3b41..404f8da 100644 (file)
@@ -23,6 +23,7 @@ import org.hedgecode.chess.pgn.entity.DetailMove;
 import org.hedgecode.chess.pgn.entity.Move;
 import org.hedgecode.chess.pgn.entity.Moves;
 import org.hedgecode.chess.pgn.entity.Variation;
+import org.hedgecode.chess.pgn.nag.Glyph;
 
 import static org.hedgecode.chess.pgn.PGNConstants.*;
 
@@ -103,6 +104,8 @@ public class ExportMovesFormat extends AbstractMovesFormat {
     private String formatAddition(DetailMove move) {
         StringBuilder sb = new StringBuilder();
         sb.append(
+                formatNag(move)
+        ).append(
                 formatComment(move)
         ).append(
                 formatVariation(move)
@@ -110,6 +113,16 @@ public class ExportMovesFormat extends AbstractMovesFormat {
         return sb.toString();
     }
 
+    private String formatNag(DetailMove move) {
+        StringBuilder sb = new StringBuilder();
+        for (Glyph glyph : move.glyphs()) {
+            sb.append(
+                    String.format(NAG_FORMAT, glyph.number())
+            ).append(PGN_SPACE);
+        }
+        return sb.toString();
+    }
+
     private String formatComment(DetailMove move) {
         StringBuilder sb = new StringBuilder();
         for (String comment : move.comments()) {