When game logic gets complex, private helper functions keep code clean and reusable.
The _endGame Helper:
We need to end the game from two places: when someone wins/draws, and when someone claims forfeit.
Instead of duplicating code, create a helper: function _endGame(address _winner, bool isDraw) private
Naming Convention:
Private internal functions often start with an underscore: _endGame
This makes it clear they're not part of the public interface.
What _endGame Does:
1. Set gameOver = true;
2. Set winner = _winner;
3. Store the pot: uint256 pot = stake;
4. If draw, split pot: both players get their stake back
5. If win, winner gets double: credits[_winner] += pot;
6. Reset game state so a new game can start
7. Emit GameEnded event
Create the _endGame helper function with proper win/draw logic.