Add existence checks and fix bug with gameboard hover (#3)

master
Garrett Mills 4 years ago
parent c0bb45a078
commit 22e489b075
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

@ -134,7 +134,7 @@ export default class GameBoardComponent extends Component {
} }
// Don't allow placing on existing ships // 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 ) { if ( is_valid_hover ) {
this.ship_ghost_cells = ghost_cells this.ship_ghost_cells = ghost_cells
@ -153,7 +153,7 @@ export default class GameBoardComponent extends Component {
* @return {boolean} * @return {boolean}
*/ */
is_ship_cell(row_i, col_i) { 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)
} }
/** /**

Loading…
Cancel
Save