If Player O never accepts, Player X should be able to cancel and get their stake back.
Cancel Requirements:
Only Player X can cancel: require(msg.sender == playerX, "Only starter can cancel");
The accept deadline must have passed: require(block.timestamp > acceptDeadline, "Accept period not expired");
Game hasn't been accepted yet: require(!gameAccepted, "Game already accepted");
Refunding the Stake:
We'll use a credits system for safety. Store the refund amount: credits[playerX] += stake;
Then reset the game state: stake = 0;gameActive = false;
First, add the state variable: mapping(address => uint256) public credits;
Then create the cancelUnaccepted() function.