Raven7 commited on
Commit
c2ce6ca
Β·
verified Β·
1 Parent(s): 81f24ba

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +58 -27
index.html CHANGED
@@ -300,18 +300,29 @@
300
  return starPoints.some(point => point[0] === row && point[1] === col);
301
  }
302
 
303
- handleMove(e) {
304
- const row = parseInt(e.target.dataset.row);
305
- const col = parseInt(e.target.dataset.col);
306
 
307
- if(this.isValidMove(row, col)) {
308
- this.placeStone(row, col);
309
-
310
- if(this.gameMode === 'ai' && this.currentPlayer === 'white') {
311
- setTimeout(() => this.makeAIMove(), 500);
 
 
 
 
 
 
 
 
312
  }
313
- }
314
  }
 
 
 
315
 
316
  isValidMove(row, col) {
317
  if(this.board[row][col] !== null) return false;
@@ -325,17 +336,30 @@
325
  return !suicide || captures.length > 0;
326
  }
327
 
328
- placeStone(row, col) {
329
- this.board[row][col] = this.currentPlayer;
330
- this.renderStone(row, col);
331
-
332
- const captures = this.checkCaptures(row, col);
333
- this.removeCaptures(captures);
334
-
335
- this.lastMove = [row, col];
336
- this.currentPlayer = this.currentPlayer === 'black' ? 'white' : 'black';
337
- this.updateDisplay();
338
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
339
 
340
  renderStone(row, col) {
341
  const intersection = document.querySelector(`[data-row="${row}"][data-col="${col}"]`);
@@ -427,14 +451,21 @@
427
  return this.isGroupCaptured(group);
428
  }
429
 
430
- pass() {
431
- this.currentPlayer = this.currentPlayer === 'black' ? 'white' : 'black';
432
- this.updateDisplay();
433
-
434
- if(this.gameMode === 'ai' && this.currentPlayer === 'white') {
435
- setTimeout(() => this.makeAIMove(), 500);
 
 
 
 
436
  }
437
- }
 
 
 
438
 
439
  reset() {
440
  this.board = Array(this.size).fill().map(() => Array(this.size).fill(null));
 
300
  return starPoints.some(point => point[0] === row && point[1] === col);
301
  }
302
 
303
+ handleMove(e) {
304
+ const row = parseInt(e.target.dataset.row);
305
+ const col = parseInt(e.target.dataset.col);
306
 
307
+ if (this.gameMode === 'ai' && this.currentPlayer === 'white') {
308
+ return; // AI μ°¨λ‘€μ—λŠ” ν”Œλ ˆμ΄μ–΄κ°€ λŒμ„ 놓을 수 μ—†μŒ
309
+ }
310
+
311
+ if (this.isValidMove(row, col)) {
312
+ this.placeStone(row, col);
313
+
314
+ if (this.gameMode === 'ai' && this.currentPlayer === 'white') {
315
+ setTimeout(() => {
316
+ if (this.difficulty === 'easy') {
317
+ this.makeRandomMove();
318
+ } else {
319
+ this.makeStrategicMove();
320
  }
321
+ }, 500);
322
  }
323
+ }
324
+ }
325
+
326
 
327
  isValidMove(row, col) {
328
  if(this.board[row][col] !== null) return false;
 
336
  return !suicide || captures.length > 0;
337
  }
338
 
339
+ placeStone(row, col) {
340
+ if (this.board[row][col] !== null) return;
341
+
342
+ this.board[row][col] = this.currentPlayer;
343
+ this.renderStone(row, col);
344
+
345
+ const captures = this.checkCaptures(row, col);
346
+ this.removeCaptures(captures);
347
+
348
+ this.lastMove = [row, col];
349
+ this.currentPlayer = this.currentPlayer === 'black' ? 'white' : 'black';
350
+ this.updateDisplay();
351
+
352
+ // AI μ°¨λ‘€ μžλ™ 진행
353
+ if (this.gameMode === 'ai' && this.currentPlayer === 'white') {
354
+ setTimeout(() => {
355
+ if (this.difficulty === 'easy') {
356
+ this.makeRandomMove();
357
+ } else {
358
+ this.makeStrategicMove();
359
+ }
360
+ }, 500);
361
+ }
362
+ }
363
 
364
  renderStone(row, col) {
365
  const intersection = document.querySelector(`[data-row="${row}"][data-col="${col}"]`);
 
451
  return this.isGroupCaptured(group);
452
  }
453
 
454
+ pass() {
455
+ this.currentPlayer = this.currentPlayer === 'black' ? 'white' : 'black';
456
+ this.updateDisplay();
457
+
458
+ if (this.gameMode === 'ai' && this.currentPlayer === 'white') {
459
+ setTimeout(() => {
460
+ if (this.difficulty === 'easy') {
461
+ this.makeRandomMove();
462
+ } else {
463
+ this.makeStrategicMove();
464
  }
465
+ }, 500);
466
+ }
467
+ }
468
+ }
469
 
470
  reset() {
471
  this.board = Array(this.size).fill().map(() => Array(this.size).fill(null));