-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update script #12
base: main
Are you sure you want to change the base?
update script #12
Conversation
const [p1RoundsWon, setp1RoundWon] = useState(0); | ||
const [p2RoundsWon, setp2RoundWon] = useState(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can use a single state variable for player 1 and 2?
src/App.jsx
Outdated
if (newCurrCards[0].rank > newCurrCards[1].rank) { | ||
const newP1Score = p1RoundsWon + 1; | ||
setp1RoundWon(newP1Score); | ||
} | ||
if (newCurrCards[0].rank < newCurrCards[1].rank) { | ||
const newP2Score = p2RoundsWon + 1; | ||
setp2RoundWon(newP2Score); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would happen if your deck goes down to 0 cards?
<Row> | ||
<Col className="column">Player 1 drew {currCardElems[0]}</Col> | ||
<Col className="column">and</Col> | ||
<Col className="column">Player 2 drew {currCardElems[1]}</Col> | ||
</Row> | ||
<Row> | ||
<Col className="column">Player 1 Score</Col> | ||
<Col className="column">vs.</Col> | ||
<Col className="column">Player 2 Score</Col> | ||
</Row> | ||
<Row> | ||
<Col className="column">{p1RoundsWon}</Col> | ||
<Col className="column">vs.</Col> | ||
<Col className="column">{p2RoundsWon}</Col> | ||
</Row> | ||
<Row> | ||
<Col className="column"> | ||
<Button variant="primary" onClick={dealCards}> | ||
{ButtonText1} | ||
</Button> | ||
</Col> | ||
<Col className="column"> | ||
<Button variant="secondary" onClick={handleReset}> | ||
{ButtonText} | ||
</Button> | ||
</Col> | ||
</Row> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you do have some opportunity here to create components for the repeating elements. By not doing that, your App component is getting a bit messy
Co-authored-by: Flashrob <38381396+Flashrob@users.noreply.github.com>
No description provided.