From 9ccbbe1790644a456de7fbb487bf231c03ec5be0 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Mon, 7 Sep 2020 15:05:23 -0500 Subject: [PATCH] Add in enum values for player, game state, grid cell state (#2) --- src/module/util.js | 50 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/module/util.js b/src/module/util.js index 8f66827..ef6fe98 100644 --- a/src/module/util.js +++ b/src/module/util.js @@ -1,5 +1,53 @@ - +/** + * Enum of all possible states of a grid cell. + * @type {object} + */ export const GridCellState = { + // Empty cell, default state Available: 'available', + + // Disabled. Ship cannot be placed here. Disabled: 'disabled', + + // There is a ship in this cell. + Ship: 'ship', + + // This cell contains part of a ship which was damaged but not sunk + Damaged: 'damaged', + + // This cell contains part of a ship which was sunk + Sunk: 'sunk', + + // This cell was targeted, but nothing was hit + Missed: 'missed', +} + +/** + * Enum of all possible players. + * @type {object} + */ +export const Player = { + One: 'player_one', + Two: 'player_two', +} + +/** + * Enum of all possible game states. These are player-agnostic. + * @type {object} + */ +export const GameState = { + // Both players are choosing the number of ships to play with (1-5) + ChoosingNumberOfShips: 'choosing_number_of_ships', + + // A player is placing their ships + PlayerSetup: 'player_setup', + + // We are prompting to change to the other player + PromptPlayerChange: 'prompt_player_change', + + // It is the player's turn to fire a missle at their opponent + PlayerTurn: 'player_turn', + + // A player has won + PlayerVictory: 'player_victory', }