Class: GameBoardComponent

GameBoardComponent()

A component which represents a single, programmable game board.

Constructor

new GameBoardComponent()

Source:

Extends

  • Component

Members

bound_fns :Array.<function()>

Array of functions bound to event listeners. Used to remove event listeners on destroy.
Type:
  • Array.<function()>
Source:

column_labels :Array.<string>

The various column labels to display.
Type:
  • Array.<string>
Source:

current_placement :string

The ship currently being placed.
Type:
  • string
Source:

ready :boolean

If true, the grid is ready to be rendered. If false, the grid will be hidden.
Type:
  • boolean
Source:

shift_pressed :boolean

Set to true when the shift key is pressed.
Type:
  • boolean
Source:

ship_ghost_cells :Array.<number>

Array of coordinates as [row_index, column_index] of cells which should show a ghost ship overlay.
Type:
  • Array.<number>
Source:

Methods

is_ghost_cell(row_i, col_i) → {boolean}

Returns a truthy value if the given cell is a ghost ship.
Parameters:
Name Type Description
row_i number
col_i number
Source:
Returns:
Type
boolean

is_ship_cell(row_i, col_i) → {boolean}

Returns true if the cell at [row_index, column_index] is a ship.
Parameters:
Name Type Description
row_i number
col_i number
Source:
Returns:
Type
boolean

on_cell_click(row_i, cell_i)

Called when a user clicks a cell. If in placement mode, will attempt to place a ship. If in missile mode, will attempt to fire a missile.
Parameters:
Name Type Description
row_i number the index of the row
cell_i number the index of the cell
Source:

on_cell_hover(row_i, cell_i)

Called when the user hovers over a cell. When in placement mode, this updates the cells that show the ghost ship.
Parameters:
Name Type Description
row_i number
cell_i number
Source:

on_keydown(event)

When keydown, check if shift was pressed. If so, update the placement.
Parameters:
Name Type Description
event
Source:

on_keyup(event)

When keyup, check if shift was released. If so, update the placement.
Parameters:
Name Type Description
event
Source:

on_mouse_leave()

Hide the ghost ship when the mouse leaves the grid.
Source:

(async) vue_on_create() → {Promise.<void>}

Called when the component is initialized.
Source:
Returns:
Type
Promise.<void>

(async) vue_on_destroy() → {Promise.<void>}

Called when the component is destroyed.
Source:
Returns:
Type
Promise.<void>