Allow TS to import countShips internally
This commit is contained in:
parent
762e2bdb1b
commit
1167c10707
1 changed files with 4 additions and 3 deletions
|
|
@ -1,14 +1,15 @@
|
||||||
/**
|
/**
|
||||||
|
* @internal
|
||||||
* A helper method for counting how many ships are on each side of a specific
|
* A helper method for counting how many ships are on each side of a specific
|
||||||
* ship on the board.
|
* ship on the board.
|
||||||
*
|
*
|
||||||
* @param board The array of spaces that represents the Gravwell board
|
* @param board The array of spaces that represents the Gravwell board
|
||||||
* @param shipLocation The index of the ship that we are counting the number of
|
* @param shipLocation The index of the ship that we are counting the number of
|
||||||
* ships on each side for.
|
* ships on each side for.
|
||||||
* @returns An object containing the number of ships that are on each side of
|
* @returns An object containing the number of ships that are on each side of
|
||||||
* the target ship
|
* the target ship
|
||||||
*/
|
*/
|
||||||
function countShips(board: any[], shipLocation: number) {
|
export function countShips(board: any[], shipLocation: number) {
|
||||||
return {
|
return {
|
||||||
left: board.slice(1, shipLocation - 1).filter(x => x != null).length,
|
left: board.slice(1, shipLocation - 1).filter(x => x != null).length,
|
||||||
right: board.slice(shipLocation + 1).filter(x => x != null).length,
|
right: board.slice(shipLocation + 1).filter(x => x != null).length,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue