function testReceiveFunction() public {
uint256 initialBalance = address(game).balance;
uint256 initialPot = game.pot();
uint256 initialPlatformFees = game.platformFeesBalance();
uint256 initialWinningsPlayer1 = game.pendingWinnings(player1);
assertEq(initialBalance, 0, "Initial contract balance should be 0");
console2.log("Initial contract balance: %s", initialBalance);
assertEq(initialPot, 0, "Initial pot should be 0");
assertEq(initialPlatformFees, 0, "Initial platform fees should be 0");
console2.log("Initial pot: %s", initialPot);
console2.log("Initial platform fees: %s", initialPlatformFees);
assertEq(initialWinningsPlayer1, 0, "Initial winnings for player1 should be 0");
vm.prank(player1);
(bool success, ) = address(game).call{value: 1 ether}("");
assertTrue(success, "Direct ETH transfer should succeed");
assertEq(address(game).balance, 1 ether, "Contract balance should increase by 1 ETH");
console2.log("Contract balance after accidental ETH: %s", address(game).balance);
assertEq(game.pot(), initialPot, "Pot should not increase");
assertEq(game.platformFeesBalance(), initialPlatformFees, "Platform fees should not increase");
console2.log("Pot after accidental ETH: %s", game.pot());
console2.log("Platform fees after accidental ETH: %s", game.platformFeesBalance());
assertEq(game.pendingWinnings(player1), initialWinningsPlayer1, "Pending winnings should not increase");
vm.prank(player1);
game.claimThrone{value: INITIAL_CLAIM_FEE}();
assertEq(game.currentKing(), player1, "Player1 should be current king");
assertEq(game.pot(), INITIAL_CLAIM_FEE * 95 / 100, "Pot should increase by claim amount minus platform fee");
assertEq(game.platformFeesBalance(), INITIAL_CLAIM_FEE * 5 / 100, "Platform fees should increase");
console2.log("Pot after claim: %s", game.pot());
console2.log("Platform fees after claim: %s", game.platformFeesBalance());
assertEq(address(game).balance, 1 ether + INITIAL_CLAIM_FEE, "Contract balance should include accidental ETH and claim");
console2.log("Contract balance after claim: %s", address(game).balance);
vm.warp(block.timestamp + GRACE_PERIOD + 1);
vm.prank(player2);
game.declareWinner();
assertEq(game.pendingWinnings(player1), INITIAL_CLAIM_FEE * 95 / 100, "Pending winnings should equal pot");
vm.prank(player1);
game.withdrawWinnings();
assertEq(game.pendingWinnings(player1), 0, "Pending winnings should be reset");
assertEq(address(game).balance, 1 ether + (INITIAL_CLAIM_FEE * 5 / 100), "Contract balance should retain accidental ETH and platform fees");
console2.log("Contract balance after player1 withdraws winnings: %s", address(game).balance);
vm.prank(deployer);
game.withdrawPlatformFees();
assertEq(game.platformFeesBalance(), 0, "Platform fees should be reset");
assertEq(address(game).balance, 1 ether, "Contract balance should retain only accidental ETH");
console2.log("Contract balance after owner withdraws platform fees: %s", address(game).balance);
assertEq(game.pot(), 0, "Pot should remain 0");
assertEq(game.platformFeesBalance(), 0, "Platform fees should remain 0");
assertEq(game.pendingWinnings(player1), 0, "Pending winnings should remain 0");
}