Home Reference Source Repository
public class | source

DartsBaseGame

Direct Subclass:

Darts501Game

Provides all the logic to create multiplier games based on this class

Constructor Summary

Public Constructor
public

constructor(players: Player[], options: Object)

Initializes a new instance of the DartsBaseGame class.

Member Summary

Public Members
public get
public get
public get
public get

players: Player[]: *

public get

Method Summary

Public Methods
public

addPlayer(player: Player)

Adds a player to the game.

public

addPlayers(players: Player[])

Add multiple players to the game.

public

Invalidates specific round.

public

invalidateThrow(dartsThrow: Throw)

Invalidates specific throw.

public

Sets currentPlayer to the next one.

public

Creates new instance of the Round for each player.

public
public

throw(num: number, multiplier: number): Throw

Represents single throw.

public

Public Constructors

public constructor(players: Player[], options: Object) source

Initializes a new instance of the DartsBaseGame class.

Params:

NameTypeAttributeDescription
players Player[]

Collection of players.

options Object
  • optional
  • default: {}

Options.

Public Members

public get currentPlayer: Player: * source

Return:

Player

Return Player

public get currentRound: Round: * source

Return:

Round

Return Round.

public get currentRoundNumber: number: * source

Return:

number

Round number.

public get players: Player[]: * source

Return:

Player[]

Array of players.

public get throwsPerRound: number: * source

Return:

number

Throws per round.

Public Methods

public addPlayer(player: Player) source

Adds a player to the game.

Params:

NameTypeAttributeDescription
player Player

Instance of Player class.

public addPlayers(players: Player[]) source

Add multiple players to the game.

Params:

NameTypeAttributeDescription
players Player[]

Array of players.

public invalidateRound(round: Round) source

Invalidates specific round.

Params:

NameTypeAttributeDescription
round Round

Round instance.

public invalidateThrow(dartsThrow: Throw) source

Invalidates specific throw.

Params:

NameTypeAttributeDescription
dartsThrow Throw

Throw instance.

public nextPlayer(): Player source

Sets currentPlayer to the next one.

Return:

Player

Returns player.

public nextRound() source

Creates new instance of the Round for each player.

public roundsByPlayer(player: Player): Round[] source

Params:

NameTypeAttributeDescription
player Player

Instance of the Player.

Return:

Round[]

Array of rounds.

public throw(num: number, multiplier: number): Throw source

Represents single throw. Delegates its execution to the currentRound object.

Params:

NameTypeAttributeDescription
num number

Number between 0 and 20 plus 25 (bull)

multiplier number
  • optional
  • default: 1

Multiplier is between 1 and 3 for all of the numbers but 25 (which has only x2 multiplier).

Return:

Throw

Throw instance.

public throwsByPlayer(player: Player): Throw[] source

Params:

NameTypeAttributeDescription
player Player

Instance of the Player.

Return:

Throw[]

Array of Throw instances.