I'm making a Rock-Paper-Scissors-Lizard-Spock (Big Bang Theory, the tv show) using ReactJS and i'm facing some kind of abstract issue.
switch (this.state.playerOnePick === 'Rock') {
case((this.state.playerTwoPick === 'Scissors') || (this.state.playerTwoPick === 'Lizard')):
return (
<div>
<h1>Player One wins !</h1>
<h2>P1: {this.state.playerOnePick} P2: {this.state.playerTwoPick}</h2>
</div>
);
break;
case((this.state.playerTwoPick === 'Paper') || (this.state.playerTwoPick === 'Spock')):
return (
<div>
<h1>Player Two wins !</h1>
<h2>P1: {this.state.playerOnePick}
P2: {this.state.playerTwoPick}</h2>
</div>
);
break;
}
switch (this.state.playerOnePick === 'Lizard') {
case((this.state.playerTwoPick === 'Spock') || (this.state.playerTwoPick === 'Paper')):
return (
<div>
<h1>Player One wins !</h1>
<h2>P1: {this.state.playerOnePick} P2: {this.state.playerTwoPick}</h2>
</div>
);
break;
case((this.state.playerTwoPick === 'Scissors') || (this.state.playerTwoPick === 'Rock')):
return (
<div>
<h1>Player Two wins !</h1>
<h2>P1: {this.state.playerOnePick} P2: {this.state.playerTwoPick}</h2>
</div>
);
break;
}
Rock vs Paper is returning the right results, no matter who's picking it, when P1: Rock, P2: Lizard, P1 wins as expected, but when P1: Lizard P2: Rock, it is returning that P1 wins..
What it returns me when P1:Lizard P2:Rock
There is nowhere where Lizard is supposed to win vs Rock...
(playerOnePick and playerTwoPick are correctly updated as the player pick a weapon)
Aucun commentaire:
Enregistrer un commentaire