From a4f13f0d17dfa15db84e0a679f0250f5c86974dd Mon Sep 17 00:00:00 2001 From: garrettmills Date: Tue, 8 Sep 2020 07:38:24 -0500 Subject: [PATCH] Add util method for checking if cell can be fired upon (#2) --- src/module/util.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/module/util.js b/src/module/util.js index e618f95..cf2d52e 100644 --- a/src/module/util.js +++ b/src/module/util.js @@ -35,6 +35,18 @@ export function isShipCell(grid_cell_state) { ].includes(grid_cell_state) } +/** + * Returns true if the given grid cell state can be fired upon. + * @param {GridCellState} grid_cell_state + * @return {boolean} + */ +export function isValidTargetCell(grid_cell_state) { + return [ + GridCellState.Ship, + GridCellState.Available, + ].includes(grid_cell_state) +} + /** * Enum of all possible players. * @type {object}