Skip to content

Marina - high card game#61

Open
Mannushka wants to merge 8 commits intorocketacademy:mainfrom
Mannushka:main
Open

Marina - high card game#61
Mannushka wants to merge 8 commits intorocketacademy:mainfrom
Mannushka:main

Conversation

@Mannushka
Copy link

No description provided.

determineLastRound = () => {
let numOfRoundsLeft = this.state.cardDeck.length / 2;
if (numOfRoundsLeft === 0) {
this.setState({ isItLastRound: true });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.setState({ isItLastRound: true });
this.setState({ isLastRound: true });

Comment on lines +84 to +106
const gameDirections = this.state.isItLastRound
? `Click "Reset the game" to start a new game.`
: `Click "Deal" to draw cards.`;
const currRoundWinnerOutput = this.state.currRoundWinner
? `Player ${this.state.currRoundWinner} won this round.`
: `It's a tie!`;
const playerOneNumOfWinsOutput = `Player 1 has ${this.state.playerOneNumOfWins} wins.`;
const playerTwoNumOfWinsOutput = `Player 2 has ${this.state.playerTwoNumOfWins} wins.`;

const numOfRoundsLeftOutput = `Number of rounds left: ${
this.state.cardDeck.length / 2
}`;
//logic to determine the game winner
let gameWinner = null;
if (this.state.playerOneNumOfWins > this.state.playerTwoNumOfWins) {
gameWinner = 1;
}
if (this.state.playerTwoNumOfWins > this.state.playerOneNumOfWins) {
gameWinner = 2;
}
const gameWinnerOutput = gameWinner
? `Player ${gameWinner} won the game!`
: `It's a tie!`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not exactly a fan of all these evaluations. I would rather use conditional rendering for these instead of storing all this in variables and redefining it constantly.

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