-
-
Notifications
You must be signed in to change notification settings - Fork 143
fix: promoting moves are animated #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: promoting moves are animated #221
Conversation
|
@antonryoung02 is attempting to deploy a commit to the Ryan Gregory's projects Team on Vercel. A member of the Team first needs to authorize it. |
| return; | ||
| } | ||
|
|
||
| if (Object.keys(positionUpdates).length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (Object.keys(positionUpdates).length === 0) { | |
| // this extra position check will only run if the position HAS changed, but we have been unable to identify the pieces that have moved, reducing the impact of the performance overhead | |
| if (Object.keys(positionUpdates).length === 0) { |
| chessColumnToColumnIndex(pawnSquare[0], noOfColumns, 'black') - | ||
| chessColumnToColumnIndex(promotionSquare[0], noOfColumns, 'black'), | ||
| ); | ||
| if (columnDifference > 1 || oldPiece[0] !== newPiece[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (columnDifference > 1 || oldPiece[0] !== newPiece[0]) { | |
| // ensure piece has moved at most 1 column away and is the same colour | |
| if (columnDifference > 1 || oldPiece[0] !== newPiece[0]) { |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Description
I added
utils.getPromotionUpdatesandutils.pawnPromotesAtSquaresto identify promoting moves.In the animation useEffect I added a condition where the promotion is animated only if
positionUpdatesdoesn't have any pieces to animate andpromotionUpdateshas one piece to animate. I added these constraints to simplify the problem, because the main benefit of the fix is to animate when only the promotion move is being played or undone. In other cases it can be hard to verify if the promotion actually happened or how you should handle conflicts withpositionUpdates.Fixes #220
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
I didn't write any unit tests for my logic because I didn't see a test suite to add them to. Let me know if I'm misunderstanding storybook!
Checklist:
Screenshots (if appropriate):
Additional context
Add any other context about the pull request here.