This is a 2 Player dice game.
react, useState, conditional rendering.
- Fork this repository.
- Clone the forked app from your github account.
- navigate inside the clone repository folder and run following command.
npm install
- To install the dependenciesnpm start
- To Start running the application.
- This a 2 player game.
- There will be two dices, each with one player.
- Players will roll the dice at their respective turns.
- A random number will be genrated between 1 and 6 when a player rolls a dice (use
Math.random()
). - Whatever random number that has been genrated by the dice will get added to that player's score.
- Each player can roll a dice maximum of 5 times.
- At the end the player with the highest score will win.
-
The App will have a Turn Banner, displaying whose turn is it, Player 1 or Player 2?
- The initial text there will be
Player 1, It is your turn!!
. - This shows that player 1 will roll the dice first.
Player 2: Roll Dice
, button will be disabled here.
- The initial text there will be
-
Player 1 score should increse by whatever value dice is throwing.
-
Once the Player 1 has rolled the dice the banner should display
Player 2, It is your turn!!
- At this point the
Player 1: Roll Dice
, button will be diabled.
- At this point the
-
The Player 2 score should increse by whatever value dice is throwing.
-
This can only be done five times, so you can take a counter 1 and counter 2 which will track how many turns the respective players have already played.
-
Once the counter 1 and counter 2 reaches 5, it should display the winner and both the buttons namely
Player 1: Roll Dice
&Player 2: Roll Dice
will be desabled as per the screenshot. -
Once, the winner has been declared the turn banner will show
Game Over!!
as the text in it.
Note
- Make sure you use only the given components and dont create new Components, files, folders of your own. Changing component name, file/folder structures might result in giving you zero marks
- Do Not Remove
data-testid="xxxx"
from anywhere, these are used by testing tools to test your code, removal of this will lead to low score. - Also make sure to cross check all the spellings and Case of Texts, as per the following screenshot as the test cases are written accordingly and it could lead in less marks.
- You can focus on your own style, but first priority is implementing all the functionalities.
-
Why and what is react?
-
Able to use CRA and run the application.
-
Basic understanding of JSX.
-
Difference between State and props.
-
Conditional rendering.
-
Props Passing.
-
Handling basic onClick events.