Created
November 21, 2019 18:18
-
-
Save winnekes/e4c913230c7a38de63e14ca90f9a712f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (user1.choice !== 'no choice' && user2.choice !== 'no choice') { | |
if (user1.choice === user2.choice) { | |
updatedRoom = await room.update({ | |
status: 'game is over', | |
winner: `oh, it's a tie!`, | |
}); | |
} else { | |
if (user1.choice === ROCK) { | |
if (user2.choice === SCISSORS) { | |
updatedRoom = await room.update({ | |
status: 'game is over', | |
winner: user1.username, | |
}); | |
const winnerGetsPoints = await user1.increment( | |
'points' | |
); | |
} | |
} else { | |
updatedRoom = await room.update({ | |
status: 'game is over', | |
winner: user2.username, | |
}); | |
const winnerGetsPoints = await user2.increment('points'); | |
} | |
if (user1.choice === SCISSORS) { | |
if (user2.choice === PAPER) { | |
updatedRoom = await room.update({ | |
status: 'game is over', | |
winner: user1.username, | |
}); | |
const winnerGetsPoints = await user1.increment( | |
'points' | |
); | |
} | |
} else { | |
updatedRoom = await room.update({ | |
status: 'game is over', | |
winner: user2.username, | |
}); | |
const winnerGetsPoints = await user2.increment('points'); | |
} | |
if (user1.choice === PAPER) { | |
if (user2.choice === SCISSORS) { | |
updatedRoom = await room.update({ | |
status: 'game is over', | |
winner: user2.username, | |
}); | |
const winnerGetsPoints = await user2.increment( | |
'points' | |
); | |
} | |
} else { | |
updatedRoom = await room.update({ | |
status: 'game is over', | |
winner: user1.username, | |
}); | |
const winnerGetsPoints = await user1.increment('points'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment