0.3.1 • Published 1 month ago

usevault v0.3.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

useVault Hook

npm version

A React hook for creating a Vault score tracker. Written in Typescript.

Created by Jameson Brown @ Atomic10 Studio
Designed by Christopher Brown @ Barely Fiction Experiences

Installation

NPM

npm i usevault

Usage

const { gameState, addPlayer, ... } = useVault({ rounds: rounds })

Properties

PropTypeDescriptionDefault
roundsnumberThe number of rounds per game.10
roundTransitionDelaynumberThe number of ms for the transition between rounds.2000

Return Values

ValueTypeDescription
gameStateGameStateThe state of the game to provide key details.
gameState.round_overbooleanIf the current round has ended(7 out or all vaulted). roundTransitionDelay is the delay till this value auto resets.
gameState.game_overbooleanIf the game has ended(all rounds completed).
gameState.current_roundnumberThe number of the current round.
gameState.total_roundsnumberThe total number of rounds for the game. Set with props.rounds defaulting to 10.
gameState.playersPlayers[]List of players that doesn't change.
gameState.roll_queuePlayers[]List of players that reflects updates to turns, score, if vaulted, etc.
gameState.roll_historyRoll[]List of roll history. Length can be used for roll count, sum of roll.value can be used for round total.
addPlayerfunctionFunction to add new player to gameState.players and gameState.roll_queue.
removePlayerfunctionFunction to remove player from gameState.players and gameState.roll_queue.
rollDicefunctionFunction to record a new dice roll.
undoRollfunctionFunction to undo last dice roll. Can only undo dice roll from current round.
vaultfunctionFunction to vault a player with the current round score.
replayfunctionFunction to replay/restart a new round. Can update players and round count after calling this function but before rollDice
0.3.1

1 month ago

0.3.0

1 month ago

0.2.0

1 month ago

0.1.0

1 month ago