Skip to content

Fix bug -> Click more than 2 cards within 500ms waiting will cause problem.#31

Open
suyangzuo wants to merge 1 commit into
kubowania:masterfrom
suyangzuo:master
Open

Fix bug -> Click more than 2 cards within 500ms waiting will cause problem.#31
suyangzuo wants to merge 1 commit into
kubowania:masterfrom
suyangzuo:master

Conversation

@suyangzuo
Copy link
Copy Markdown

@suyangzuo suyangzuo commented Aug 11, 2022

In the original version, Due to checkForMatch will run after 500ms delay, so if click more than 2 cards within 500ms, the cardsChosen.length will longer than 2.

And, the checkForMatch will run only on condition cardsChosen.length === 2, so cardsChosen[2], cardsChosen[3] maybe after will not trigger checkForMatch.

This commit move the cardsChosen = [] and cardsChosenId = [] out of checkForMatch and put them into flipCard before checkForMatch runs, and use copy to replace them in checkForMatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants