Skip to content

Commit f82f34e

Browse files
committed
Do not start new game immediately after end
1 parent 686747e commit f82f34e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

js/game.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default class Game {
77
#playerO
88

99
#onTurn = 'X'; // Odd rounds => X starts, even rounds => O starts
10+
#end = false;
1011
#xWins = 0;
1112
#oWins = 0;
1213
#ties = 0;
@@ -54,6 +55,12 @@ export default class Game {
5455
}
5556

5657
#handleClick(e, index) {
58+
if (this.#end) {
59+
this.#end = false;
60+
this.#resetBoard();
61+
return;
62+
}
63+
5764
// Square already taken
5865
if (this.#state[index] !== '') {
5966
return;
@@ -110,9 +117,9 @@ export default class Game {
110117
this.#oWins++;
111118
}
112119

120+
this.#end = true;
113121
this.#saveScore(winner);
114122
this.#updateScore();
115-
this.#resetBoard();
116123
}
117124

118125
#saveScore(winner) {

0 commit comments

Comments
 (0)