Constructor
new Player(area, targets, opponentPlayerName, name)
Parameters:
| Name | Type | Description |
|---|---|---|
area |
Object | This repreents the battle area of the player |
targets |
Array | Array of all the predefined targets |
opponentPlayerName |
string | Name of the opponent |
name |
string | player's name |
Methods
getNextTarget(targetIndex) → {string}
Function to get next target of the player
Parameters:
| Name | Type | Description |
|---|---|---|
targetIndex |
Number | : index of the desired target |
Returns:
target at the index
- Type
- string
isDefeated() → {Boolean}
Function to check if the player is deafted or not
Returns:
returns true if area is destroyed else false
- Type
- Boolean
takeHit(coordinates) → {boolean}
Function to take a hit on this player
Parameters:
| Name | Type | Description |
|---|---|---|
coordinates |
string | : hit target |
Returns:
returns true if hit else false
- Type
- boolean