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. |
Members
-
<nullable> catChannel :Discord~CategoryChannel
-
The category that stores all channels for this game. Null until it is created.
Type:
- Discord~CategoryChannel
-
<constant> createTimestamp :number
-
The timestamp at which this game was first created.
Type:
- number
-
<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
-
<readonly> id :number
-
The ID of this uno game. Should be unique per guild.
Type:
- number
-
<constant> lastInteractTimestamp :number
-
The timestamp at which this game was last interacted with.
Type:
- number
-
<readonly> started :boolean
-
Has this game been started.
Type:
- boolean
-
<private, inner> currentCollector
-
The current Discord~MessageCollector that is listening to messages in the groupChannel.
-
<private, inner> direction :number
-
The current direction of play. Either 1 or -1.
Type:
- number
-
<private, inner> discarded :Array.<Uno.Card>
-
All cards currently not in a player's hand.
Type:
- Array.<Uno.Card>
-
<private, inner, constant> members :object.<Discord~GuildMember>
-
The guild members in this game mapped by their ID.
Type:
- object.<Discord~GuildMember>
-
<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)>
-
<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
-
<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
-
<private, inner> turn :number
-
The current index of the player whose turn it is.
Type:
- number
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. 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. Returns:
Success if true, failed if false.- Type
- boolean
-
end()
-
Ends this game and deletes all created channels.
-
getPlayers()
-
Returns the list of all players currently in this game.
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. 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. -
<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. -
<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. 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. -
<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. -
<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.
-
<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.
-
<inner> listPlayers()
-
Send the list of current players in this game to the group channel.
-
<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. -
<private, inner> parseToCard(text)
-
Parse a string of text to a playable card.
Parameters:
Name Type Description text
string The user-input to parse. 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. 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.
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.