Skip to content

Commit f62909a

Browse files
committed
Add timeout after game end
1 parent 61a10fa commit f62909a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

js/game.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default class Game {
88

99
#onTurn = 'X'; // Odd rounds => X starts, even rounds => O starts
1010
#end = false;
11+
#endTimeout = false;
1112
#xWins = 0;
1213
#oWins = 0;
1314
#ties = 0;
@@ -58,6 +59,9 @@ export default class Game {
5859
}
5960

6061
#handleClick(e, index) {
62+
if (this.#endTimeout) {
63+
return;
64+
}
6165
if (this.#end) {
6266
this.#end = false;
6367
this.#resetBoard();
@@ -130,6 +134,9 @@ export default class Game {
130134
})
131135

132136
this.#end = true;
137+
this.#endTimeout = true;
138+
setTimeout(() => { this.#endTimeout = false; }, 1500);
139+
133140
this.#saveScore(winner);
134141
this.#updateScore(winner);
135142
}

0 commit comments

Comments
 (0)