LibChess: Fixed PGN export bug (#7300)

In cases with ambiguous captures involving pawns (where multiple pieces
could have made the capture), we were exporting invalid syntax for
the move:

`1. e4 e5 2. Bb5 c6 3. Bxc6 ddxc6`

Move 3 should be `Bxc6 dxc6`, but we were duplicating the d on the pawn
move.
This commit is contained in:
Josh Perry 2021-05-20 07:32:19 +01:00 committed by GitHub
parent 4a2dd5bf66
commit c46ab4fbb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-18 17:43:36 +09:00

View File

@ -199,7 +199,7 @@ String Move::to_algebraic() const
} }
if (is_capture) { if (is_capture) {
if (piece.type == Type::Pawn) if (piece.type == Type::Pawn && !is_ambiguous)
builder.append(from.to_algebraic().substring(0, 1)); builder.append(from.to_algebraic().substring(0, 1));
builder.append("x"); builder.append("x");
} }