From 37903ae7dd75dcaf4fd9a685c84de56a74ec1f68 Mon Sep 17 00:00:00 2001 From: zthoffman21 Date: Sun, 23 Feb 2025 12:45:29 -0500 Subject: [PATCH] changed getAdjCells() to reference 'this.board' because using 'board' produces incorrect results --- js/cell.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/js/cell.js b/js/cell.js index da060c5..0562ab0 100644 --- a/js/cell.js +++ b/js/cell.js @@ -10,16 +10,16 @@ class Cell { getAdjCells() { var adj = []; - var lastRow = board.length - 1; - var lastCol = board[0].length - 1; - if (this.row > 0 && this.col > 0) adj.push(board[this.row - 1][this.col - 1]); - if (this.row > 0) adj.push(board[this.row - 1][this.col]); - if (this.row > 0 && this.col < lastCol) adj.push(board[this.row - 1][this.col + 1]); - if (this.col < lastCol) adj.push(board[this.row][this.col + 1]); - if (this.row < lastRow && this.col < lastCol) adj.push(board[this.row + 1][this.col + 1]); - if (this.row < lastRow) adj.push(board[this.row + 1][this.col]); - if (this.row < lastRow && this.col > 0) adj.push(board[this.row + 1][this.col - 1]); - if (this.col > 0) adj.push(board[this.row][this.col - 1]); + var lastRow = this.board.length - 1; + var lastCol = this.board[0].length - 1; + if (this.row > 0 && this.col > 0) adj.push(this.board[this.row - 1][this.col - 1]); + if (this.row > 0) adj.push(this.board[this.row - 1][this.col]); + if (this.row > 0 && this.col < lastCol) adj.push(this.board[this.row - 1][this.col + 1]); + if (this.col < lastCol) adj.push(this.board[this.row][this.col + 1]); + if (this.row < lastRow && this.col < lastCol) adj.push(this.board[this.row + 1][this.col + 1]); + if (this.row < lastRow) adj.push(this.board[this.row + 1][this.col]); + if (this.row < lastRow && this.col > 0) adj.push(this.board[this.row + 1][this.col - 1]); + if (this.col > 0) adj.push(this.board[this.row][this.col - 1]); return adj; }