Spaces:
Running
Running
Upload script.js
Browse filesFixed a bug where a score would be given when a player pressed the correct number immediately after the enemy had answered it correctly.
script.js
CHANGED
@@ -229,6 +229,7 @@
|
|
229 |
const correct = Math.random() < aiAccuracy;
|
230 |
if (correct) {
|
231 |
const idx = remaining.findIndex(item => item.num === currentTarget);
|
|
|
232 |
if (idx === -1) return;
|
233 |
const item = remaining[idx];
|
234 |
aiScore++;
|
@@ -270,6 +271,7 @@
|
|
270 |
if (clickX >= item.x && clickX <= item.x + item.width &&
|
271 |
clickY <= item.y && clickY >= item.y - item.height) {
|
272 |
if (item.num === currentTarget) {
|
|
|
273 |
if (gameMode === 'vsAI') {
|
274 |
if (aiTimeout) {
|
275 |
clearTimeout(aiTimeout);
|
|
|
229 |
const correct = Math.random() < aiAccuracy;
|
230 |
if (correct) {
|
231 |
const idx = remaining.findIndex(item => item.num === currentTarget);
|
232 |
+
currentTarget = null;
|
233 |
if (idx === -1) return;
|
234 |
const item = remaining[idx];
|
235 |
aiScore++;
|
|
|
271 |
if (clickX >= item.x && clickX <= item.x + item.width &&
|
272 |
clickY <= item.y && clickY >= item.y - item.height) {
|
273 |
if (item.num === currentTarget) {
|
274 |
+
currentTarget = null;
|
275 |
if (gameMode === 'vsAI') {
|
276 |
if (aiTimeout) {
|
277 |
clearTimeout(aiTimeout);
|