Member Summary
Public Members | ||
public |
Event container |
|
public |
The player number (starting at 0 for the host) |
|
public |
The players’ unique user IDs |
Method Summary
Public Methods | ||
public |
createDeck(cardFaces: CardFace[]): Deck Creates and shuffles a new deck for the game |
|
public |
Creates a new die for the game |
|
public |
createPiece(id: string): Piece Creates a movable piece for the game |
|
public |
Gets the number of currently connected players |
|
public |
Get the game URL which other users can use to connect |
|
public |
start() Starts the game for all players |
|
public |
Starts the P2P connection |
Public Members
public on: Object<string, Signal> source
Event container
Properties:
Name | Type | Attribute | Description |
playerJoin | Signal | Event signal when a player joins the game (Parameter: userID) |
|
playerLeave | Signal | Event signal when a player leaves the game (Parameter: userID) |
|
start | Signal | Event signal when the game starts (No parameters) |
Public Methods
public createDeck(cardFaces: CardFace[]): Deck source
Creates and shuffles a new deck for the game
Params:
Name | Type | Attribute | Description |
cardFaces | CardFace[] | The deck’s card faces (max. 52) |
Throw:
when cardFaces has under 2 or over 52 elements |
public createDie(id: string, dieFaces: number | DieFace[]): Die source
Creates a new die for the game
Throw:
when dieFaces has under 2 or over 52 elements |
public createPiece(id: string): Piece source
Creates a movable piece for the game
Params:
Name | Type | Attribute | Description |
id | string | The piece’s id |
public getNumberOfPlayers(): Promise<number, ConnectionNotStartedError> source
Gets the number of currently connected players
public getURL(): string source
Get the game URL which other users can use to connect
Throw:
when startConnection() was not called before |
public start() source
Starts the game for all players
Emit:
the game starts |
Throw:
when startConnection() was not called before |
public startConnection() source
Starts the P2P connection
Test:
- Game #startConnection() opens a new connection if no URL hash is set
- Game #startConnection() sets the URL hash when new connection is opened
- Game #startConnection() sets the player number to 0 if new connection is opened
- Game #startConnection() connects if a URL hash is set
- Game #startConnection() doesn’t set the player number to 0 if connected to other host