Class: Player

TankGame.Player()

Class Player that represents the player

Constructor

new Player()

Constructor for the player object
Source:

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
Source:
Throws:
Invalid weapon type
Type
Error

attachTank(tank)

Add a tank handle to the player
Parameters:
Name Type Description
tank TankGame.Tank The tank.
Source:
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.
Source:
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
Source:

draw()

Draw the player information in a bar at the top of the screen
Source:

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
Source:
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
Source:
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.
Source:

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.
Source:

peekNextWeapon() → {TankGame.ProjectileParam}

Get the next type of weapon
Source:
Returns:
- The next weapon type
Type
TankGame.ProjectileParam

shootNextWeapon()

Decrease current weapon count
Source:

Documentation generated by JSDoc 4.0.2 on Wed Oct 29 2025 23:51:02 GMT-0700 (Pacific Daylight Time)