Bug fix - Pawn promotion is represented incorrectly on game object moves list #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses an issue where pawn promotion doesn't reflect in the original move object inside MoveTree.
If promoting a piece by using the game.make(move: from:) function, the game object does not know of the user selected piece after the promotion, nor does it update the move object at any point.
So for example if we initialize a game object with the following fen: "4kb1r/Pb2qpp1/2pp1n1p/1rn1p3/4P3/1BNP1N2/2P2PPP/R1BQ1RK1 w k - 1 14"
the move pawn on a7 to a8 will be annotated by the SANParser as simply "a8" since the value for promotedPiece is nil.
I didn't want to tie board and game objects because those should be able to operate independently, so I passed the responsibility of notifying the game object about the promoted piece to the developer.