Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

update script #12

wants to merge 2 commits into from

Conversation

Cnkh6069
Copy link

No description provided.

Comment on lines +17 to +18
const [p1RoundsWon, setp1RoundWon] = useState(0);
const [p2RoundsWon, setp2RoundWon] = useState(0);

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
Comment on lines 27 to 34
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);
}

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?

src/App.jsx Outdated Show resolved Hide resolved
Comment on lines +87 to +113
<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>

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants