This is a simple rock paper scissors implementation in JavaScript.
This project requires npm in order to install dependencies.
npm install
Tests
Execute
grunt test
to run unit tests and generate test coverage report.
The natural extension of this game would probably be Rock-paper-scissors-lizard-Spock. This can be achieved by simply extending the constraint object in the RockPaperScissors class.
Here's a quick example for lizard
this.constraints = {
rock: {
name: 'Rock',
beats: {
scissors: 'crushes', // rock crushes scissors
lizard: 'crushes' // rock crushes lizard
}
},
scissors: {
name: 'Scissors',
beats: {
paper: 'cut', // scissors cut paper
lizard: 'decapitates' // scissors decapitate lizard
}
},
paper: {
name: 'Paper',
beats: {
rock: 'covers' // paper covers rock
}
},
lizard: {
name: 'Lizard',
beats: {
paper: 'eats' // lizard eats paper
}
},
};