Skip to content

Commit

Permalink
Fix wrong PGN format when first move is black to play (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
govind-maheshwari2 authored Apr 24, 2024
1 parent 9938b90 commit 70d9ff6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/src/game/game_outputs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,14 @@ extension GameOutputs on Game {
int firstTurn = history.first.turn;
int turn = firstTurn;
String pgn = '';
for (int i = 0; i < moves.length; i++) {
if (i == 0 || turn == Bishop.white) pgn = '$pgn${firstMove + i ~/ 2}. ';
if (i == 0 && turn == Bishop.black) pgn = '$pgn..';
for (int i = 0; i < moves.length; i++) {
if (i == 0 || turn == Bishop.white)
pgn =
'$pgn${firstMove + i ~/ 2}${(i == 0 && turn == Bishop.black) ? "" : ". "}';
if (i == 0 && turn == Bishop.black) {
pgn = '$pgn... ';
firstMove++;
}
pgn = '$pgn${moves[i]} ';
turn = turn.opponent;
}
Expand Down

0 comments on commit 70d9ff6

Please sign in to comment.