URI:
       fix notating files and rank for piece moves - chess-puzzles - chess puzzle book generator
  HTML git clone git://git.codemadness.org/chess-puzzles
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 887918beab1aba026f2c228bb8ef770d420d338e
   DIR parent 32c2e6a2c44fba3b0242123894dcacf79f59578f
  HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Tue, 11 Jun 2024 15:42:26 +0200
       
       fix notating files and rank for piece moves
       
       Do not notate files and ranks for pawn moves (requires only file).
       Do not allow to output the same file twice.
       
       Diffstat:
         M fen.c                               |      31 ++++++++++++++-----------------
       
       1 file changed, 14 insertions(+), 17 deletions(-)
       ---
   DIR diff --git a/fen.c b/fen.c
       @@ -1302,27 +1302,24 @@ board_playmoves(struct board *b, const char *moves)
                                        }
        
                                        /* pawn move needs no notation */
       -                                if (piece != 'p' && piece != 'P')
       +                                if (piece != 'p' && piece != 'P') {
                                                pgn("%c", pgnpiece(piece));
        
       -                                /* check ambiguity for certain pieces and make the notation shorter */
       -                                countambigousmoves(b, side, piece, x, y, x2, y2, px, py,
       -                                        &countfile, &countrank, &countboard);
       +                                        /* check ambiguity for certain pieces and make the notation shorter */
       +                                        countambigousmoves(b, side, piece, x, y, x2, y2, px, py,
       +                                                &countfile, &countrank, &countboard);
        
       -                                if (countfile > 1) {
       -                                        pgn("%c", xtofile(x));
       -                                        speak("%c", xtofile(x));
       -                                }
       -                                if (countrank > 1) {
       -                                        pgn("%c", ytorank(y));
       -                                        speak("%c", ytorank(y));
       -                                }
       -                                if (countboard > 1) {
       -                                        pgn("%c", xtofile(x));
       -                                        speak("%c", xtofile(x));
       +                                        if (countfile > 1 || countboard > 1) {
       +                                                pgn("%c", xtofile(x));
       +                                                speak("%c", xtofile(x));
       +                                        }
       +                                        if (countrank > 1) {
       +                                                pgn("%c", ytorank(y));
       +                                                speak("%c", ytorank(y));
       +                                        }
       +                                        if (countfile > 1 || countrank > 1 || countboard > 1)
       +                                                speak(" ");
                                        }
       -                                if (countfile > 1 || countrank > 1 || countboard > 1)
       -                                        speak(" ");
        
                                        if (tookpiece) {
                                                /* pawn captures are prefixed by the file letter (no more needed) */