Members
(inner) copyGameCodeTimeoutID :number|undefined
TimeoutID for use by copyGameCodeToClipboard()
Type:
- number | undefined
- Source:
(inner) currentAnimationPromise :Promise.<void>
Promise that will resolve when the current card animation process
is complete, for use with other out-of-context animation functions
Type:
- Promise.<void>
- Source:
Methods
(static) handleGameEnd(gameWinner)
Displays end-of-game information, namely who won
Parameters:
| Name | Type | Description |
|---|---|---|
gameWinner |
Types.ServerToClientProfile | profile data of (user/opponent) who won game |
- Source:
(static) handleGameStart(drawnCardNames)
Displays start of game instance, including cards being drawn
Parameters:
| Name | Type | Description |
|---|---|---|
drawnCardNames |
Array.<Types.Card> | cards "drawn" by the user, passed from server |
- Source:
(static) handleInstanceClosed()
Handles event where instance is completely closed out, including displaying a message
to the user and forcing them back to the lobby
- Source:
(static) handleOpponentMove(optionsopt)
Displays fact that opponent user has played a card, without yet revealing what
that card is
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
Object |
<optional> |
- Source:
(static) handleRevealCards(opponentSelectedCard, roundWinner)
Calls animateRevealCards and awaits response, for use by other dependent animations
Parameters:
| Name | Type | Description |
|---|---|---|
opponentSelectedCard |
Types.Card | information of card chosen by opponent |
roundWinner |
Types.ServerToClientProfile | profile data of (user/opponent) who won round |
- Source:
(static) handleStartRound()
Handles reset of UI at the start of each new round
- Source:
(static) handleUpdateInstance(instanceInfo)
Updates display of current user lobby, including game code and active players
Parameters:
| Name | Type | Description |
|---|---|---|
instanceInfo |
Object | new info about game instance |
- Source:
(static) handleWorldEvent(worldEvent, worldEventName)
Handles world event action, updating the game legend and triggering popup
Parameters:
| Name | Type | Description |
|---|---|---|
worldEvent |
string | world event that was triggered |
worldEventName |
- Source:
(static) initializeVersus()
Initializes Versus game; initializes WebSocket, connects appropriate callbacks,
and activates event listeners
- Source:
(static) refreshEntireGame()
Rebuilds entire game board; can be used to resolve errors and in the case of
re-joining instances
- Source:
(inner) animateCardDealing(cardEl, versusCardEl, delaySec)
Animates card sliding into either user's or opponent's hand, including applicable
sound effect(s)
Parameters:
| Name | Type | Description |
|---|---|---|
cardEl |
HTMLElement | versus-card element to attach animation to |
versusCardEl |
||
delaySec |
number | seconds of delay until animation should start |
- Source:
(async, inner) animateRevealCards(opponentSelectedCard, roundWinner)
Handles async animation of card reveal promise, for use by handleRevealCards()
Parameters:
| Name | Type | Description |
|---|---|---|
opponentSelectedCard |
Types.Card | information of card chosen by opponent |
roundWinner |
Types.ServerToClientProfile | profile data of (user/opponent) who won round |
- Source:
(async, inner) copyGameCodeToClipboard()
Copies game code to user's clipboard (i.e., so they can paste it instead of having
to remember it)
- Source:
(inner) createCardElements()
Adds card images to the DOM at start of game
- Source:
(inner) displayWinner(winnerUUID, variant)
Displays message that a user won the round/game
Parameters:
| Name | Type | Description |
|---|---|---|
winnerUUID |
Types.UUID | winner of round/game |
variant |
'round' | 'game' | decorator on win message |
- Source:
(inner) displayWorldEventLegendImage()
Displays (without animation) the legend image for the current
world event associated to the game, for use when triggering
a complete refresh of the game state
- Source:
(async, inner) handleCardSelection(e)
Relays card selection to server during gameplay, and relocates
corresponding card to center screen
Parameters:
| Name | Type | Description |
|---|---|---|
e |
MouseEvent | click event passed by event listener |
- Source:
(inner) handleLeaveGame()
Provides user with a modal asking them if they indeed want to leave the game
instance
- Source:
(inner) initializeScoreboard()
Initializes score, round, and time remaining counters
located on the game board
- Source:
(inner) refreshOppSelectedCard()
Rebuilds and replaces the opponent's (unrevealed) selected card,
for use during full-game refresh
- Source:
(inner) refreshUserSelectedCard()
Rebuilds and replaces the users's selected card, for use during\
full-game refresh
- Source:
(inner) returnToLobby()
Handles complete return to lobby, and reset of all currentl game state and displays
- Source:
(async, inner) roundWinnerAnimationCard(roundWinnerUUID) → {Promise.<void>}
Animation that shows which card won for each show
Parameters:
| Name | Type | Description |
|---|---|---|
roundWinnerUUID |
Types.UUID | unique identifier of round winner |
- Source:
Returns:
promise that resolves when animation is complete
- Type
- Promise.<void>
(async, inner) roundWinnerAnimationText(roundWinnerUUID) → {Promise.<void>}
Animation that shows either "YOU WON" or "YOU LOST" depending on the outcome for each round
Parameters:
| Name | Type | Description |
|---|---|---|
roundWinnerUUID |
Types.UUID | unique identifier of round winner |
- Source:
Returns:
promise that resolves when animation is complete
- Type
- Promise.<void>
(inner) sanitizeGameCode()
Removes everything but digits 0-9 from the game code input box, called
whenever the value changes
- Source:
(inner) sendJoinInstance()
Relays attempt to join new game instance to server while in lobby
- Source:
(inner) showGameLobbyInfoModal()
Shows modal explaining how game codes work to the user
- Source:
(inner) showRulesModal()
Shows modal explaining the rules to a user
- Source:
(inner) toggleToGameboardView()
Switch to view of game board
- Source:
(inner) toggleToLobbyView()
Switch to view of lobby, and focus on game code input element
- Source:
(inner) translateWorldEvent()
Animates world event popup to replace current legend;
at the end of the animation, the legend will be moved
into the container in the DOM as well
- Source:
(inner) updateCurrentInstruction(…newChildEls)
Inserts new content into the instruction box, overriding any existing content
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
newChildEls |
string | Node |
<repeatable> |
new elements or strings to insert |
- Source:
(inner) updateScoreboardRoundNumber()
Populates scoreboard round number with current round from store
- Source:
(inner) updateScoreboardScores()
Populates scoreboard scores with most recent scores from store
- Source: