Class: Game

Uno# Game


new Game(memberList, maker)

Class that stores the current state of an Uno game.
Parameters:
Name Type Description
memberList Array.<Discord~GuildMember> The players to initially add to this game.
maker Discord~GuildMember The player who created the game and can change settings and manage users.
Source:

Members


<nullable> catChannel :Discord~CategoryChannel

The category that stores all channels for this game. Null until it is created.
Type:
  • Discord~CategoryChannel
Source:

<constant> createTimestamp :number

The timestamp at which this game was first created.
Type:
  • number
Source:

<nullable> groupChannel :Discord~TextChannel

The channel that all players of this game can view and type in. Null until the channel is created.
Type:
  • Discord~TextChannel
Source:

<readonly> id :number

The ID of this uno game. Should be unique per guild.
Type:
  • number
Source:

<constant> lastInteractTimestamp :number

The timestamp at which this game was last interacted with.
Type:
  • number
Source:

<readonly> started :boolean

Has this game been started.
Type:
  • boolean
Source:

<private, inner> currentCollector

The current Discord~MessageCollector that is listening to messages in the groupChannel.
Default Value:
  • type {?Discord~MessageCollector}
Source:

<private, inner> direction :number

The current direction of play. Either 1 or -1.
Type:
  • number
Default Value:
  • 1
Source:

<private, inner> discarded :Array.<Uno.Card>

All cards currently not in a player's hand.
Type:
  • Array.<Uno.Card>
Source:

<private, inner, constant> members :object.<Discord~GuildMember>

The guild members in this game mapped by their ID.
Type:
  • object.<Discord~GuildMember>
Source:

<private, inner, constant> players :Array.<(Uno.Player|Uno.NPC)>

The array of all player in the game in the order of their turn.
Type:
  • Array.<(Uno.Player|Uno.NPC)>
Source:

<private, inner> previousTurn :number

The index of the player whose turn it was previously. This is -1 if the current turn is the first turn of the game, and will otherwise be the previous player to play a card.
Type:
  • number
Source:

<private, inner, nullable> topCard :Uno.Card

The current card on the top of the discard pile that will need to be matched by the next player to play a card.
Type:
  • Uno.Card
Source:
See:
  • Uno.Game~previousCard

<private, inner> turn :number

The current index of the player whose turn it is.
Type:
  • number
Source:

Methods


addNPCs( [num])

Add a certain number of NPCs into the game.
Parameters:
Name Type Argument Default Description
num number <optional>
1 The number of NPCs to add.
Source:
Returns:
Success if true, failed if false.
Type
boolean

addPlayer(p)

Add the given guild member to the game.
Parameters:
Name Type Description
p Discord~GuildMember The member to add to the game.
Source:
Returns:
Success if true, failed if false.
Type
boolean

end()

Ends this game and deletes all created channels.
Source:

getPlayers()

Returns the list of all players currently in this game.
Source:
Returns:
Array of player IDs. Type is number-like.
Type
Array.<string> | Array.<number>

removeNPCs( [num])

Remove a certain number of NPCs from the game.
Parameters:
Name Type Argument Default Description
num number <optional>
1 The number of NPCs to remove.
Source:
Returns:
Success if true, failed if false.
Type
boolean

removePlayer(p)

Remove the user with the given ID from the game.
Parameters:
Name Type Description
p string | number | Discord~GuildMember | Uno.Player The ID of the user to remove.
Source:

<private, inner> callUno(caller)

A player has called Uno. To say that they are about to have one card, they now have one card after playing, or the previous person now has one card and did not call Uno.
Parameters:
Name Type Description
caller string | number The user ID of the player who called Uno.
Source:

<private, inner> checkCard(card [, card2])

Checks if the given card may be played next.
Parameters:
Name Type Argument Description
card Uno.Card The card to check.
card2 Uno.Card <optional>
The card to check against. If not defined, the current topCard will be used.
Source:
See:
  • Uno.Game~topCard
Returns:
True if can be played, false otherwise.
Type
boolean

<private, inner> drawAndSkip( [num])

Cause the current player to draw cards from the discarded pile, then skip their turn and continue to the next player.
Parameters:
Name Type Argument Default Description
num number <optional>
1 The number of cards to draw.
Source:

<private, inner> drawCards(num [, silent])

Cause the current player to draw cards from the discarded pile.
Parameters:
Name Type Argument Default Description
num number The number of cards to draw.
silent boolean <optional>
false Do not send a message to the group channel.
Source:

<private, inner> endGame()

Called after a game has been won by somebody. Clears all players of their cards, and resets the game to ready for next game state.
Source:

<private, inner> finishSetup()

Begins listening for messages in the groupChannel that relate to the setup of the game, and sends a message to the group channel with game instructions.
Source:

<inner> listPlayers()

Send the list of current players in this game to the group channel.
Source:

<private, inner> nextTurn( [skip])

Called after a player's turn, to trigger the next player's turn.
Parameters:
Name Type Argument Default Description
skip boolean <optional>
false True to add additional message saying this player is skipped. Also doesn't send the player their hand. True if this turn is intended to be skipped.
Source:

<private, inner> parseToCard(text)

Parse a string of text to a playable card.
Parameters:
Name Type Description
text string The user-input to parse.
Source:
Returns:
The matched card, or null if no match.
Type
Uno.Card

<private, inner> playCard(text)

Play a card for the current player.
Parameters:
Name Type Argument Description
text string <nullable>
User inputted text to parse into a card to play.
Source:
Returns:
True if the game has ended. False if the game should continue.
Type
boolean

<private, inner> sendHelp()

Sends the game help to the group channel.
Source:
Returns:
Promise of command help being sent to the channel.
Type
Promise.<Discord~Message>

<private, inner> startGame()

Deal cards to all players, and start the game.
Source: