Explain solidity>state cleanup

State Cleanup

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.

Create _resetGame helper and integrate it
0%
Requirements:
Declares _resetGame function
_resetGame is private
Clears board with loop
Resets gameAccepted to false
Resets acceptDeadline to 0
Resets lastMoveAt to 0
_endGame calls _resetGame
startGame calls _resetGame
startGame removes old board loop