Class: Uno

Uno

Manages an Uno game.

new Uno()

Source:
Listens to Events:
  • Command#event:uno

Extends

Classes

Card
Game

Members


<readonly> bot :boolean

Whether this player is a Discord bot or not.
Type:
  • boolean
Overrides:
Default Value:
  • false
Source:

calledUno :boolean

Whether this player has called uno recently.
Type:
  • boolean
Source:

calledUno :boolean

Whether this player has called uno recently.
Type:
  • boolean
Source:

<constant> CardFace :number

Enum for card faces. The two least significant nibbles are the card face. The most significant used nibbles are for card effects (designated by the `EFFECT_MASK`). BASE_MASK is the bitwise not of EFFECT_MASK, except on only the nibbles that are less significant than EFFECT_MASK. 0x01000: The card is a wild card. 0x02000: The card skips the next player's turn. 0x04000: The card reverses play direction. 0x08000: The card causes the next player after the turn is over, to draw 2 cards. 0x10000: The next player must draw 4 cards. EFFECT entries are NOT real card faces, just the bitfield represented with that effect.
Type:
  • number
Properties:
Name Type Default Description
EFFECT_MASK number 1044480
BASE_MASK number 4095
WILD_EFFECT number 4096
SKIP_EFFECT number 8192
REVERSE_EFFECT number 16384
DRAW_TWO_EFFECT number 32768
DRAW_FOUR_EFFECT number 65536
SKIP number 8208
DRAW_TWO number 40992
DRAW_2 number 40992
REVERSE number 16432
WILD number 4160
DRAW_FOUR number 77904
DRAW_4 number 77904
ZERO number 0
0 number 0
ONE number 1
1 number 1
TWO number 2
2 number 2
THREE number 3
3 number 3
FOUR number 4
4 number 4
FIVE number 5
5 number 5
SIX number 6
6 number 6
SEVEN number 7
7 number 7
EIGHT number 8
8 number 8
NINE number 9
9 number 9
Source:

<readonly, nullable> channel :Discord~TextChannel

The channel for this player's private messages for the game. Null until the channel is created.
Type:
  • Discord~TextChannel
Source:

client :Discord~Client

The current bot client. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
  • Discord~Client
Inherited From:
Source:

<constant> Color :number

Enum for card colors.
Type:
  • number
Properties:
Name Type Default Description
NONE number 0
RED number 1
BLUE number 2
GREEN number 3
YELLOW number 4
Default Value:
  • {"NONE":0,"RED":1,"BLUE":2,"GREEN":3,"YELLOW":4}
Source:

command :Command

The command object for registering command listeners. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
Inherited From:
Source:

<constant> commit :string

The commit at HEAD at the time this module was loaded. Essentially the version of this submodule.
Type:
  • string
Inherited From:
Source:

common :Common

The common object. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
Inherited From:
Source:

delayCallUno :number

Delay before calling uno if this NPC is going to call it. (Milliseconds).
Type:
  • number
Default Value:
  • 3000
Source:

Discord :Discord

The current Discord object instance of the bot. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
  • Discord
Inherited From:
Source:

hand :Array.<Uno.Card>

The current cards that this player has in their hand.
Type:
  • Array.<Uno.Card>
Source:

hand :Array.<Uno.Card>

The current cards that this player has in their hand.
Type:
  • Array.<Uno.Card>
Source:

<abstract> helpMessage :undefined|string|Discord~EmbedBuilder

The help message to show the user in the main help message.
Type:
  • undefined | string | Discord~EmbedBuilder
Inherited From:
Source:

<readonly> id :string

The Discord ID of this player.
Type:
  • string
Source:

<readonly> id :string

The ID of this npc. Must be uniqueness is not enforced, but is required.
Type:
  • string
Source:

<protected, readonly> initialized :boolean

Has this subModule been initialized yet (Has begin() been called).
Type:
  • boolean
Inherited From:
Source:

<constant> loadTime :number

The time at which this module was loaded for use in checking if the module needs to be reloaded because the file has been modified since loading.
Type:
  • number
Inherited From:
Source:

<readonly> mention :string

String for mentioning this user in chat.
Type:
  • string
Source:

<readonly> mention :string

String for mentioning this user in chat.
Type:
  • string
Source:

<protected> myName :string

The name of this submodule. Used for differentiating in the log. Should be defined before begin().
Type:
  • string
Inherited From:
Overrides:
Source:

<readonly> name :string

The name of this player.
Type:
  • string
Source:

<readonly> name :string

The name of this player.
Type:
  • string
Source:

<readonly> npc :boolean

Whether this player is a npc or not. Must be false. Use Uno.NPC for bots.
Type:
  • boolean
Default Value:
  • false
Source:

<readonly> npc :boolean

Whether this player is a NPC or not. Always true.
Type:
  • boolean
Default Value:
  • true
Source:

<abstract> postPrefix :string

The postfix for the global prefix for this subModule. Must be defined before begin(), otherwise it is ignored.
Type:
  • string
Inherited From:
Source:

probCallUno :number

Probability this NPC will call uno when necessary.
Type:
  • number
Default Value:
  • 0.5
Source:

<private, inner, constant> cardFacePairs

CardFace as entries.
Source:

<private, inner, constant> cardFaceRegExp :RegExp

Regular expression search for acceptable card faces. Case insensitive and global flags are set.
Type:
  • RegExp
Source:

<private, inner, constant> colorPairs

Color as entries.
Source:

<private, inner, constant> colorRegExp :RegExp

Regular expression search for acceptable colors. Case insensitive and global flags are set.
Type:
  • RegExp
Source:

<private, inner, constant> games :object.<object.<Uno.Game>>

All games currently in progress mapped by guilds, then by the game ID.
Type:
  • object.<object.<Uno.Game>>
Source:

<private, inner, constant> maxPlayerCount :number

Maximum number of players allowed in a game.
Type:
  • number
Default Value:
  • 10
Source:

<private, inner, constant> npcDelay :number

Delay for NPC to play their card.
Type:
  • number
Default Value:
  • 5000
Source:

<private, inner, constant> npcNames :Array.<string>

Default names of NPCs to add when adding non-bot NPCs.
Type:
  • Array.<string>
Default Value:
  • ["HAL","Jane","HEX","Deep Thought","Com Pewter","EDI","JARVIS","Samantha","TARS","Ava","Friday","Legion","Cortana","GLaDOS","Guilty Spark","2B","9S","CL4P-TP","Computer","NPC","AI","Bot","CPU","R2D2","AUTO","CASE","Alexa","Bixby"]
Source:

<private, inner> numGames :number

The number of currently active games. Used to determine of submodule is unloadable.
Type:
  • number
Source:

<private, inner> pFlags

Self.Discord.Permissions.Flags.
Source:

<private, inner, constant> unoText :string

ASCII art text to show when a player calls Uno.
Type:
  • string
Source:

Methods


begin(Discord, client, command, common, bot)

Initialize this submodule.
Parameters:
Name Type Description
Discord Discord The Discord object for the API library.
client Discord~Client The client that represents this bot.
command Command The command instance in which to register command listeners.
common Common Class storing common functions.
bot SpikeyBot The parent SpikeyBot instance.
Inherited From:
Source:

<protected> debug(msg)

Log using common.logDebug, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Source:

end()

Trigger subModule to shutdown and get ready for process terminating.
Inherited From:
Source:

<protected> error(msg)

Log using common.error, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Source:

getHand()

A default hand of cards that the classic game starts with.
Source:
Returns:
An array of all cards in a deck.
Type
Array.<Uno.Card>

<protected> initialize()

The function called at the end of begin() for further initialization specific to the subModule. Must be defined before begin() is called.
Inherited From:
Overrides:
Source:

<protected> log(msg)

Log using common.log, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Source:

NPC(name, parent [, options])

A single non-player character in the game. This is the same as a normal player, except they are not given a text channel, and their actions are controlled by us.
Parameters:
Name Type Argument Description
name string The display name of this NPC.
parent Uno.Game The parent game this player will be in.
options NPCOpts <optional>
Optional options for this NPC.
Source:

Player(member, parent)

A single player in the game.
Parameters:
Name Type Description
member Discord~GuildMember The guild member this is based off of.
parent Uno.Game The parent game this player will be in.
Source:

<abstract> reloadable()

Check if this module is in a state that is ready to be reloaded. If false is returned, this module should not be unloaded and doing such may risk putting the module into an uncontrollable state. This is different from unloadable, which checks if this module can be stopped completely, this checks if the module can be stopped and restarted.
Inherited From:
Source:
See:
  • SubModule~unloadable
Returns:
True if can be reloaded, false if cannot.
Type
boolean

remove()

Remove this player from a game. Deletes the player's text channel.
Source:

remove()

Remove this player from a game. Cleans up references if any exist.
Source:

<abstract> save( [opt])

Saves all data to files necessary for saving current state.
Parameters:
Name Type Argument Default Description
opt string <optional>
'sync' Can be 'async', otherwise defaults to synchronous.
Inherited From:
Source:

<protected> shutdown()

Shutdown and disable this submodule. Removes all event listeners.
Inherited From:
Overrides:
Source:

unloadable()

Check if this module is in a state that is ready to be unloaded. If false is returned, this module should not be unloaded and doing such may risk putting the module into an uncontrollable state.
Inherited From:
Overrides:
Source:
See:
  • SubModule~reloadable
Returns:
True if can be unloaded, false if cannot.
Type
boolean

<protected> warn(msg)

Log using common.logWarning, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Source:

<private, inner> commandEndAll(msg)

Ends all Uno games.
Parameters:
Name Type Description
msg Discord~Message Message that triggered command.
Source:
Listens to Events:
  • Command#event:uno_endall

<private, inner> commandStats(msg)

Sends information about current uno games.
Parameters:
Name Type Description
msg Discord~Message Message that triggered command.
Source:
Listens to Events:
  • Command#event:uno_stats

<private, inner> commandUno(msg)

Starts an Uno game. If someone is mentioned it will start a game between the message author and the mentioned person. Otherwise, waits for someone to play.
Parameters:
Name Type Description
msg Discord~Message Message that triggered command.
Source:
Listens to Events:
  • Command#event:uno

<private, inner> formatCard(txt)

Takes a string that is all caps with underscores and makes it more human readable.
Parameters:
Name Type Description
txt string The text to format.
Source:
Returns:
The formatted text.
Type
string

<private, inner> getCardEmbed(hand)

Format a hand of cards or a single card into Discord~EmbedBuilder.
Parameters:
Name Type Description
hand Uno~Card | Array.<Uno~Card> The card or hand of cards to format.
Source:
Returns:
The EmbedBuilder to send to the user.
Type
Discord~EmbedBuilder