Skip to content

Conversation

@enzeeo
Copy link
Contributor

@enzeeo enzeeo commented May 20, 2025

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:

  1. python manage.py makemigrations
  2. python manage.py migrate
  3. python manage.py loaddata checkers-fixture.json
  4. python manage.py runserver
  5. Log in as [email protected]
  6. Reset password and confirm email address as necessary
  7. Go to games/checkers/1 and make a move. Now try making another move and you should be locked from clicking your own piece or the black piece
  8. Log in as [email protected]
  9. Reset password and confirm email address as necessary
  10. Go to games/checkers/1 and make a move. Now try making another move and you should be locked from clicking your own piece or the red piece
  11. Closing the server and opening back up should not affect gameplay e.g. if it was black's turn when you closed the server, it should still be black's turn when you resume.

@enzeeo enzeeo added this to the 2025/Sprint 4 milestone May 20, 2025
@enzeeo enzeeo requested a review from abargher May 20, 2025 03:35
@enzeeo enzeeo self-assigned this May 20, 2025
@enzeeo enzeeo linked an issue May 20, 2025 that may be closed by this pull request
@brianHarder brianHarder self-requested a review May 20, 2025 04:17
Copy link
Contributor

@brianHarder brianHarder left a 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 brianHarder self-requested a review May 20, 2025 21:44
Copy link
Contributor

@brianHarder brianHarder left a 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!

Copy link
Contributor

@abargher abargher left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Checkers] Ensure that only associated player can move pieces

4 participants