brendaninnis / satle

Satle is a Wordle-like daily geography game where you guess cities based on satellite images.
https://satle.brendaninnis.ca
5 stars 1 forks source link

Prevent submit during game state change animation #9

Open sleiphir opened 7 months ago

sleiphir commented 7 months ago

I have noticed that because of the delay caused by the animation playing while submitting an answer you can submit multiple times before the game state changes.

The animDuration is set to 300 and there are 2 setTimeout calls that use animDuration before actually changing the state of the game, which means you have effectively 600ms to submit anything, e.g if you press enter multiple times you will be able to submit "skips" even though you might have found the answer already but the game has not yet had the time to change its state.

This PR solves this problem simply by disabling the user input as the submit begins and re-enables it at the end. Another solution would be to change the state of the game instantly instead of at the end of the animations. Let me know what you think.

brendaninnis commented 7 months ago

Wow @sleiphir thanks so much for this awesome bug fix and PR. It's very much appreciated.

Looks pretty good to me I'll try it out and merge it before I push a fix for Twemoji that broke in Satle recently.