Constructor
new Game(…args)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
args |
Object |
<repeatable> |
{args_name: args_value ...}; |
- Source:
Methods
activateBonus(player)
active the bonus for all the activeplayer
Parameters:
| Name | Type | Description |
|---|---|---|
player |
string |
- Source:
addPlayer(player)
add the new player in the lobby to the playerlist
Parameters:
| Name | Type | Description |
|---|---|---|
player |
string |
- Source:
advanceStage()
advance in Stage (preflop flop,trun,river,...)
- Source:
advanceStageToShowdown()
skip the stage for go to showdown
- Source:
autoTurn(player, leftopt)
This function has to be called when a player doesn't play by himself.
By default the autoTurn is meant to be for AFK, they'r not automatically kick of the game
and they will be allowed to join back before the end of the current rounds where he will be remove
if he hasn't come back.
The function also verify if the player is master, upon which we need to search for new one.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
player |
Player | to play for. Will set him afk. | ||
left |
boolean |
<optional> |
false | left if the player left or it was an afk. By default we guess it's an afk. |
- Source:
bet(player, amount)
The player tries to bet a certain amount of coins.
There's 5 possibles outcomes :
*** RAISE *****
if : 0 < gameCurrentBet < miseTotal < allin
*** CALL *****
if : miseTotal = gameCurrentBet != allin
*** CHECK *****
if : 0 = mise = gameCurrentBet
*** ALLIN *****
if : mise = playerMoney
else invalid action and he failed to bet.
Parameters:
| Name | Type | Description |
|---|---|---|
player |
string | |
amount |
int |
- Source:
check(player)
check the player
Parameters:
| Name | Type | Description |
|---|---|---|
player |
string |
- Source:
checkForNewMaster(forced)
forced a new master if needed
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
forced |
* | false |
- Source:
createAutoRestartCall()
Create a timeout that will restart the game
if the master has checked "autoRestart".
The timeout is set to 10s
- Source:
Returns:
setTimeout | False
createAutoTurnCall()
Create a timeout specifically watching the player focus at the call moment.
If the timeout resolve the focus is still on the same player (and the player still exist)
the function call @see autoTurn
- Source:
Returns:
setTimeout
destroy()
To call to destroy the room. It will remove all timer etc...
- Source:
evaluateHands()
evaluate the hands of activePlayers
- Source:
Returns:
the winners of the game (can have multiple winers)
fold(player)
fold the player
Parameters:
| Name | Type | Description |
|---|---|---|
player |
string |
- Source:
gameEnd()
reveal the cards and move all the afk players to a spectator state.
Start the restartTimer and the autoRestarTimer
- Source:
getActivePlayers()
filter the ActivePlayers in the player array
- Source:
Returns:
a tab of Activeplayer
getFocus()
- Source:
Returns:
the focus player
getForPlayer(id)
This function generate a specific view of the game for the player given
This filter everything the player is not allowed to see by creating a
new Object for everything in the game (all the players too) to prevent any memory sharing.
This is the main security to prevent anyone from seeing someone else cards.
This means that even though you can spectate a game you wont be able to see
any player cards and you won see anyone cards to help them :)
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | player that wants to view the game. |
- Source:
Returns:
a new view of the Game object
getMaster()
- Source:
Returns:
the id of the master of the lobby
getPlayerById(playerId)
Parameters:
| Name | Type | Description |
|---|---|---|
playerId |
string |
- Source:
Returns:
player | null
getPlayerNameById(playerId)
Parameters:
| Name | Type | Description |
|---|---|---|
playerId |
string |
- Source:
Returns:
the PlayeName
isPlayersTurn(playerId)
check if it's the player turn
Parameters:
| Name | Type | Description |
|---|---|---|
playerId |
id |
- Source:
Returns:
boolean
make7Cards(player)
Parameters:
| Name | Type | Description |
|---|---|---|
player |
string |
- Source:
Returns:
best card and id of the player
moveAfkPlayersToSpectators()
moove the afk in specator
- Source:
movePlayersWithZeroCoinsToSpectators()
Kick the poor in spectator (0 money)
- Source:
moveSpecOrPlayer(playerId)
Move the player in argument to the spectator or in the players table if he's allowed.
Parameters:
| Name | Type | Description |
|---|---|---|
playerId |
id |
- Source:
newgame()
start a newgame
- Source:
Returns:
nothing. Stop early if game cannot start.
playerPlayed()
Function for postAction callback
Not used for anything else that loggin purpose right now.
Meant for future improvement.
- Source:
removePlayer(playerId)
remove the player who leave the lobby
Parameters:
| Name | Type | Description |
|---|---|---|
playerId |
id |
- Source:
reset()
reset the lobby for a newgame
- Source:
resetRestartCall()
- Source:
rotateFocus()
rotate the focus Player and advance in the game if condition are fill
- Source:
Returns:
Stop early if we need to end the game or no one is playing.
rotateStartingPlayer()
Change the starting Player every start of a newgame
- Source:
rotateTimer()
Rotate the autoTurntimer for the current player.
- Source:
setMaster(id)
set the master at the id player
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
- Source:
setPlayerAFK(player) → {void}
Will set the player to afk, remove him from player and set him as spectator
Parameters:
| Name | Type | Description |
|---|---|---|
player |
Player | Player class Object |
- Source:
Returns:
- Type
- void
start(playerId)
start the game
Parameters:
| Name | Type | Description |
|---|---|---|
playerId |
id |
- Source:
Returns:
stop early if the game cannot start.
toggleRestart(playerId)
Parameters:
| Name | Type | Description |
|---|---|---|
playerId |
string |
- Source:
updateActivePlayers()
update the ActviePlayer
- Source:
updatePlayersList()
update the Players list with the nonspecator and nonAfk Players
- Source: