Module: store

Members

(inner) gameState :Types.GameState

Type:
  • Types.GameState
Source:

(inner, constant) userProfilesByUUID :Types.ServerToClientProfile

Type:
  • Types.ServerToClientProfile
Source:

Methods

(static) clearGameState()

Source:

(static) createNewRoundState()

Adds blank new round to the current game state
Source:

(static) getCurrentWorldEvent() → {string}

Fetches world event associated to current round
Source:
Returns:
value of WORLD_EVENT enum
Type
string

(static) getGameIsStarted() → {boolean}

Pulls game-start status from the current game state
Source:
Returns:
true if game is started; false otherwise
Type
boolean

(static) getGameWinnerUUID() → {Types.UUID}

Fetches UUID of user that won the game
Source:
Returns:
unique ID of game winner
Type
Types.UUID

(static) getNumOpponentCards() → {number}

Fetches the number of cards that the opponent still has (cards themselves are still unknown)
Source:
Returns:
number of cards that opponent has in hand
Type
number

(static) getOppHasPlayedRound() → {boolean}

For the current round, returns whether or not the opponent player has already played a card
Source:
Returns:
true if opponent has played this round; false otherwise
Type
boolean

(static) getOpponentUUID() → {Types.UUID}

Determines the UUID of the opponent player by finding the first (only) UUID that doesn't match the client user
Source:
Returns:
UUID of opponent user
Type
Types.UUID

(static) getPlayerUUIDs() → {Array.<Types.UUID>}

Returns the UUIDs member to current game
Source:
Returns:
list of UUIDs active in game (length 2)
Type
Array.<Types.UUID>

(static) getProfile(playerUUID) → {Types.ServerToClientProfile}

Fetches last-read profile associated to a player sent from the server
Parameters:
Name Type Description
playerUUID Types.UUID unique identifer whose profile is targeted
Source:
Returns:
profile of user
Type
Types.ServerToClientProfile

(static) getRemainingCards() → {Array.<Types.Card>}

Fetches all cards that are still available in the hand of the client user
Source:
Returns:
list of remaining card names for user
Type
Array.<Types.Card>

(static) getRoundNumber() → {number}

For the current game state, returns the current number associated with the round (i.e., at the start of the game, the client is partaking in round 1)
Source:
Returns:
current round number of game state for client user
Type
number

(static) getRoundWinnerUUID() → {Types.UUID}

Fetches UUID of user that won the current round
Source:
Returns:
unique ID corresponding to round winner
Type
Types.UUID

(static) getScore(playerUUID) → {number}

Fetches game score corresponding to user profile with a given UUID
Parameters:
Name Type Description
playerUUID Types.UUID unique identifier whose score is targeted
Source:
Returns:
number of rounds won by player
Type
number

(static) getSelfHasPlayedRound() → {boolean}

For the current round, returns whether or not the client user has already played a card
Source:
Returns:
true if client user has played this round; false otherwise
Type
boolean

(static) getSelfSelectedCard() → {Types.Card|null}

Fetches card selected by the user during the current round
Source:
Returns:
card selected by the user in the current round, or null if no card has been selected
Type
Types.Card | null

(static) initializePlayers(playerUUIDs)

For a given list of members of the lobby, initializes player game state for each of them under the gameState object
Parameters:
Name Type Description
playerUUIDs Array.<Types.UUID> unique identifiers for each member of game
Source:

(static) setGameIsStarted()

Sets game-start status to true
Source:

(static) setGameState(newGameState)

Attempts to update game state by forcing a new game state object on top of the existing game state
Parameters:
Name Type Description
newGameState Types.GameState game state that takes priority
Source:

(static) setGameWinnerUUID(gameWinnerUUID)

Sets unique ID of user that won the game
Parameters:
Name Type Description
gameWinnerUUID Types.UUID unique ID of game winner
Source:

(static) setNumOpponentCards(numOpponentCards)

Sets an anonymized list of cards of same length as numOpponentCards in the data store for future access
Parameters:
Name Type Description
numOpponentCards number number of remaining cards that the opponent has
Source:

(static) setOppSelectedCard(selectedCard)

For the current round, sets the opponent's selected card and tosses out a random card from the opponent's remaining cards (b/c they are anonymized anyways)
Parameters:
Name Type Description
selectedCard Types.IndeterminateCard card selected by the opponent user, passed from the server
Source:

(static) setRemainingCards(remainingCards)

Sets list of remaining cards that can be played by client user
Parameters:
Name Type Description
remainingCards Array.<Types.Card> list of remaining card names for user
Source:

(static) setRoundWinnerUUID(playerUUID)

Sets the winner of the current/most recent round
Parameters:
Name Type Description
playerUUID Types.UUID unique identifier of round winner
Source:

(static) setSelfSelectedCard(selectedCard)

For the current round, sets the client user's selected card
Parameters:
Name Type Description
selectedCard Types.Card card selected by the client user
Source:

(static) updateProfile(profile)

Updates profile to store by UUID and emits appropriate event listener for downstream users
Parameters:
Name Type Description
profile Types.ServerToClientProfile most-recent profile sent from the server for a given user
Source: