After a game ends, we need to clean up all state so a new game can start fresh.
Another Helper Function:
Create function _resetGame() private to handle cleanup.
This keeps the code organized and reusable.
What to Reset:
Clear the board with a loop: for (uint i = 0; i < 9; i++) { board[i] = Cell.Empty; }
Reset flags: gameAccepted = false;acceptDeadline = 0;lastMoveAt = 0;
Calling Helpers:
Now update _endGame to call _resetGame at the end.
And update startGame to call _resetGame at the beginning.
This ensures every game starts with a clean slate.
Create _resetGame and integrate it into _endGame and startGame.