perennialAutodidact / memory-snap

0 stars 0 forks source link

Setup player turns - part 1 of 2 #30

Closed perennialAutodidact closed 2 months ago

perennialAutodidact commented 1 year ago

The game's turn system needs to be setup. The game context has a currentPlayerIndex object, which indicates the player whose turn it currently is. It should cycle through players 0 to n-1 where n is the total number of players. When the last player has their turn (player 2 of 2 for now), the turn will circle around to the first player again.

Note: The modulus operator % could be useful here. There could be a context property like turnCount or something that is incremented every time the player turn changes. Then that number can be "modulus'd" by the length of the players array to obtain the index of the current player in the players array.

For now: