Skip to content

CANCELLED: Game state should track previous and current player for Gist forking/editing logic #20

@LearningNerd

Description

@LearningNerd

Closing issue #3 revealed a new bug in the logic of how the app handles forking/editing Gists: right now most of the game logic depends on the state of the current and next player, but the logic for forking/editing Gists should actually depend on the state of the previous and current players! The real condition here is this: who owns the current version of the Gist? If the current player owns the current Gist, they should edit it; if not, they should fork it.

Turn change and Gist editing scenarios:

  1. First player needs to edit Gist when turn ends if first player is still connected at end of turn, regardless of any other players joining and/or disconnecting!

  2. If first player disconnects before end of first turn, they still need to edit the Gist because the server will end the turn early, and it makes sense to save the first player's progress instead of misattributing their work to the next player.

  3. Game ends if first player disconnects before end of first turn and no other players are present when the turn ends.

Tasks for this issue:

  • Initialize the game with previousPlayer and currentPlayer both pointing to the first player (the server tracks this!)
  • Add previousPlayerIndex to server's game state
  • Update server's turnChange data to include previous player data
  • Add previousPlayerId to client's game state
  • Update previous player data along with other client-side state variables inside handleTurnChange and handleUpdateState
  • Update events list and flowchart to reflect these new changes.

Note: after fixing this, the next related bug to fix (issue #21) is to then have the server handle forking/editing Gists on behalf of any user that disconnected before the end of their turn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions