Skip to content
/ tenzies Public

TENZI game built with React. Roll until all dice are the same. Click each die to freeze it at its current value between rolls

Notifications You must be signed in to change notification settings

mayaif/tenzies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

9 1 - Copy

To win the game, the player must roll the dice until they are all the same.

By selecting a dice, the player can lock its current value, preventing it from changing in subsequent rolls.

The useState() is used to define two state variables 'dice' and 'tenzies'.

'dice' stores an array of dice objects which have a value, 'isHeld' and 'id' properties.

'tenzies' is a boolean state variable that determines whether the game has been won or not.

The useEffect() is used to check whether all the dice have the same value and are being held. If this is the case, tenzies state variable is set to 'true', indicating that the game has been won.

The useEffect() hook is dependent on the 'dice' state variable, so it will be called every time the 'dice' state variable is updated. This allows the function to monitor changes to the dice variable and execute the necessary code when the conditions of the useEffect are met.

About

TENZI game built with React. Roll until all dice are the same. Click each die to freeze it at its current value between rolls

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published