From 22e489b0756548dc3db3a487228645717a740bfd Mon Sep 17 00:00:00 2001 From: garrettmills Date: Thu, 10 Sep 2020 07:48:11 -0500 Subject: [PATCH] Add existence checks and fix bug with gameboard hover (#3) --- src/components/GameBoard.component.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/GameBoard.component.js b/src/components/GameBoard.component.js index 04fd48b..476b05d 100644 --- a/src/components/GameBoard.component.js +++ b/src/components/GameBoard.component.js @@ -134,7 +134,7 @@ export default class GameBoardComponent extends Component { } // Don't allow placing on existing ships - is_valid_hover = !ghost_cells.some(([row_i, col_i]) => this.is_ship_cell(row_i, col_i)) + is_valid_hover = is_valid_hover && !ghost_cells.some(([row_i, col_i]) => this.is_ship_cell(row_i, col_i)) if ( is_valid_hover ) { this.ship_ghost_cells = ghost_cells @@ -153,7 +153,7 @@ export default class GameBoardComponent extends Component { * @return {boolean} */ is_ship_cell(row_i, col_i) { - return isShipCell(this.rows[row_i][col_i].render) + return this.rows[row_i] && this.rows[row_i][col_i] && isShipCell(this.rows[row_i][col_i].render) } /**