Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

User Can’t Reset the Game If No One Has Joined

Description

In the current implementation, the deployer is prevented from resetting the game if no one has joined.

require(currentKing != address(0), "Game: No one has claimed the throne yet.");

After the deployer deploys the game, if no one joins or claims the throne possibly because the initial claimFee was set too high the deployer might want to reset the game to adjust the claimFee.
However, they cannot do that due to the check above, hence the gameEnded can`t be change anywhere outside declareWinner()
which may lead to make the deployer needed to deploy the game one more time with extra deployment fees

Recommended Mitigation

Use the following in declareWinner() to allow resetting the game even if there’s no winner:

- require(currentKing != address(0), "Game: No one has claimed the throne yet.");
+ if (currentKing == address(0)) {
+ gameEnded = true;
+ emit GameEnded(currentKing, pot, block.timestamp, gameRound);
+ } else {
+ gameEnded = true;
+ pendingWinnings[currentKing] = pendingWinnings[currentKing] + pot;
+ pot = 0; // Reset pot after assigning to winner's pending winnings
+ emit GameEnded(currentKing, pot, block.timestamp, gameRound);
+ }
Updates

Appeal created

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

Game gets stuck if no one claims

alicrali33 Submitter
about 1 month ago
inallhonesty Lead Judge
about 1 month ago
inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

Game gets stuck if no one claims

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.