Constructor
# new Hole(player, board, id, numSeeds, prevHole, nextHole)
Constructor
Parameters:
Name | Type | Description |
---|---|---|
player |
Player
|
The player to whom this hole is being assigned to |
board |
Board
|
The board on which the hole is placed |
id |
number
|
Unique hole ID (Ranging 0-16) -1 is used for the dummy pointer to the first hole. |
numSeeds |
number
|
Number of seeds to be initially added to the hole. |
prevHole |
Hole
|
The hole that is before this hole. |
nextHole |
Hole
|
The hole that comes up next in clockwise fashion |
Methods
# adjacencyDirection(targetHole) → {MoveDirection}
Calculates the move direction that corresponds to a users drag and drop action.
Seeds are dragged from an origin hole into the target hole. The direction is only returned if
the target hole is adjacent to the origin.
Parameters:
Name | Type | Description |
---|---|---|
targetHole |
Hole
|
the hole into which the seeds are being dragged into |
the direction that corresponds to the users drag and drop action.
# availableMovesForCurrentPlayer() → {Array.<Move>}
Gets the moves that are available for the current player
moves that can be played
Array.<Move>
# isEmpty() → {boolean}
Checks to see if the hole contains any seeds
true if seeds are present
boolean
# isInFrontRow() → {boolean}
Check if this hole is in the front row (Front rows are allowed to capture
seeds from enemy side).
true is the hole is in the front row for the owning player.
boolean
# transferAllSeedsToCurrPlayer() → {number}
Moves all seeds from the hole into players hand - clearing it to a count of 0.
The number of seeds that were moved from hole into players hand.
number
# transferSeedsFromCurrPlayer(numSeeds) → {number}
Removes seeds from players hand
Parameters:
Name | Type | Description |
---|---|---|
numSeeds |
number
|
Number of seeds to be removed from players hand |
Number of seeds removed from the player hand
number
# validateFinalSeedCount(numSeeds)
Checks if the the total number of seeds in players hand is valid
Parameters:
Name | Type | Description |
---|---|---|
numSeeds |
number
|
Number of seeds in players hand after adding or removing |
# validateNumSeeds(numSeeds)
Checks if the number of seeds to be added or removed from players hand is valid
Parameters:
Name | Type | Description |
---|---|---|
numSeeds |
number
|
Number of seeds to be added or removed from players hand |