Methods
addWeapon(newWeapon, cost)
Adds the weapon to the weapons list if it within the players budget.
Parameters:
| Name | Type | Description |
|---|---|---|
newWeapon |
String | The weapon to add to the player |
cost |
Number | The cost of the weapon |
Throws:
-
Invalid weapon type
- Type
- Error
attachTank(tank)
Add a tank handle to the player
Parameters:
| Name | Type | Description |
|---|---|---|
tank |
TankGame.Tank | The tank. |
Throws:
-
param tank should be instance of TankGame.Tank
- Type
- Error
attachTo(gameEngine)
Attach the player to the game engine and keep a handle for the
game engine.
Parameters:
| Name | Type | Description |
|---|---|---|
gameEngine |
TankGame.GameEngine | The game engine. |
Throws:
-
param gameEngine should be instance of TankGame.GameEngine
- Type
- Error
dettachTank()
Remove the tank handle from the player to allow the garbage collector to
work
draw()
Draw the player information in a bar at the top of the screen
getWeaponCount(weaponType) → {Number}
Return how many of a particular weapons the player has in their inventory
Parameters:
| Name | Type | Description |
|---|---|---|
weaponType |
String | The type of weapon |
Throws:
-
Invalid Weapon type
- Type
- Error
Returns:
The number of the given weapon type the play has
- Type
- Number
isAI() → {Boolean}
Checks if the current player is AI
Returns:
If the current player is AI
- Type
- Boolean
moveToNextWeaponType()
Move the weapon selection to the next weapon type in the armoury
This method contains a debouncing feature to prevent multiple keypresses
changing weapons too quickly.
moveToPrevWeaponType()
Move the weapon selection to the previous weapon type in the armoury
This method contains a debouncing feature to prevent multiple keypresses
changing weapons too quickly.
peekNextWeapon() → {TankGame.ProjectileParam}
Get the next type of weapon
Returns:
- The next weapon type
shootNextWeapon()
Decrease current weapon count