Reference Source
public class | source

Player

A player in the WOJ game.

Constructor Summary

Public Constructor
public

constructor(id: number, name: string)

Member Summary

Public Members
public
public
public get

totalScore: numbner

Method Summary

Public Methods
public

Adds 1 token to the player's tokens.

public

Return the score for a given round number.

public

hasToken(): *

Checks if the player has any tokens.

public

resetScore(round: number)

Reset score for round to 0.

public

Sets the player's tokens to 0.

public

Deduct a token, if the player has one.

Public Constructors

public constructor(id: number, name: string) source

Params:

NameTypeAttributeDescription
id number

A unique numeric ID for the player.

name string
  • optional

the players name.

Public Members

public scores: Score[] source

public tokens: number source

public get totalScore: numbner source

Public Methods

public addToken() source

Adds 1 token to the player's tokens.

public getScore(round: number): number source

Return the score for a given round number.

Params:

NameTypeAttributeDescription
round number

number of the round, 0 is round 1.

Return:

number

score for the given round number.

public hasToken(): * source

Checks if the player has any tokens.

Return:

*

true if the player has at least one token.

public resetScore(round: number) source

Reset score for round to 0.

Params:

NameTypeAttributeDescription
round number

number of the round, 0 is round 1.

public resetTokens() source

Sets the player's tokens to 0.

public useToken(): boolean source

Deduct a token, if the player has one.

Return:

boolean

true if the token was deducted.

Throw:

Error

throws error if the player has no tokens.