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 |
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 |
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 |
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 |
on_keydown(event)
When keydown, check if shift was pressed. If so, update the placement.
Parameters:
Name | Type | Description |
---|---|---|
event |
on_keyup(event)
When keyup, check if shift was released. If so, update the placement.
Parameters:
Name | Type | Description |
---|---|---|
event |
on_mouse_leave()
Hide the ghost ship when the mouse leaves the grid.
(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.
Returns:
- Type
- Promise.<void>