-
Notifications
You must be signed in to change notification settings - Fork 0
[Checkers] Only allow player to move their piece during their turn #1199
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: dev
Are you sure you want to change the base?
Conversation
…/chigame into checkers/merge-sandbox-score
brianHarder
left a comment
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.
I followed all the instructions and was able to play as both red and black. The restrictions on pieces work properly: I can only move red pieces when logged in as red on red's turn, and I can only move black pieces when logged in as black on black's turn.
However, the forfeit and draw buttons didn't work for me. Forfeit should be pretty easy (only current player can forfeit), but draw requires the other player to be able to click accept which could get trickier. See if you can update the views or JS code to get these working.
brianHarder
left a comment
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.
Confirmed with Enzo that forfeit + draw functionality will be implemented in a later PR. With that aside, the player restriction works as expected and the code makes sense. LGTM!
abargher
left a comment
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.
There are some merge conflicts plus some issues with the migrations, please take a look.
To address issue #1190, I added a current player tracker to the CheckersBoard model. Every time a player makes a move, the move now gets tracked and the pieces are now associated with a player. This means that players can only move their own pieces, and can only move them when it is their turn to play.
To test, please run the following:
python manage.py makemigrationspython manage.py migratepython manage.py loaddata checkers-fixture.jsonpython manage.py runserver[email protected]games/checkers/1and make a move. Now try making another move and you should be locked from clicking your own piece or the black piece[email protected]games/checkers/1and make a move. Now try making another move and you should be locked from clicking your own piece or the red piece