Separated from previous issues. Taken from #21:
Problem arises from the fact that each syncing action does not advance the opponents machine. It simply updates the context. The opponent is only blocked from doing anything in 'selecting' because it entered that state with a 'currentPlayer' switch. So the UI prevents him from making a move (playerToMove(Cell.tsx:30)). This changes when sync sends an update with an updates 'currentPlayer'. But the machine has of course never left the 'selecting' state so it doesnt reload with 'setCellsAllowedToMove' and its most current cells are the "cleaned" ones send by the opponents last move.
I would like it best if the current player would send every generated event through p2p to the opponent so that it's machine can follow the process (I think this would be the cleanest).
Other, MUCH SIMPLER solution is:
- rename to onlineGame machine
- Stay in alternating after turn (rename to opponents turn).
- Still get updates from current system of sync's
- Show board while in alternating to follow process (index.tsx:40).
- Add special seperate action in SYNC handler that raises a "ADVANCETURN" event when the send 'currentPlayer' differs from the one in context (so once again equals playerId). Do this before, once again of course, updating the the values send with the SYNC.
Separated from previous issues. Taken from #21: