miya3333 commited on
Commit
e3b3029
·
verified ·
1 Parent(s): ed2ca9d

Upload script.js

Browse files

Fixed a bug where a score would be given when a player pressed the correct number immediately after the enemy had answered it correctly.

Files changed (1) hide show
  1. script.js +2 -0
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);