A rock-paper-scissors game, built in React.js. Author: Bryce Watson BryceEWatson@gmail.com
React, paper, scissors uses React.js to implement a stateful version of the game Rock, Paper, Scissors.
Don't know the game? http://en.wikipedia.org/wiki/Rock-paper-scissors
App state is used to keep track of the players, their score, and more.
The UI follows Google's Material Design specifications (https://design.google.com/)
Play it live! https://bryceewatson.github.io/rockpaperscissors/
- Ability to play against the computer
- Ability to simulate a game (Computer vs Computer)
- Ability to restart the game
- Computer generated plays are random
- Scoreboard keeps track of previous plays
- Ability to toggle between computer and human at any time
To see the application locally, run npm run dev
.
To create a distributable, run npm run build
.
To run the test suite, run npm test
.
Tests are located in /test/
, and there is a test suite for each UI component.
Tests use ReactTestUtils to render & retrieve components. PhantomJS is used for DOM interaction.
Certain changes to the game, such as increasing the number of rounds per match, can be made easily by modifying the initial state in /src/js/initial-data.js
.
Other changes, such as adding additional actions beyond 'rock', 'paper', and 'scissors', can be accomplished with some minor modifications to the player and rock-paper-scissors ui components.
### Tooling
The following tooling / libraries are used:
webpack
to modularise the Javascript codebabel
to utilise ES2015/ES6 features today in case you're into itnode-sass
to modularise your styling via SASSeslint
to make sure your code meets the standardskarma
,mocha
andchai
to help you write and run your unit tests in various browsersfile-loader
for loading SVG and other imagesreact.js
for fast rendering of stateful UI componentsReactTestUtils
for easy testing of react UI components
To start developing, fork and clone the project first, then make sure you have Node.js 5.x or higher and run
$ npm install
You have the following CLI commands available:
npm run dev
runningwebpack-dev-server
and serving the project onlocalhost
npm run test -- --browsers Chrome
running unit tests viakarma
in Chromenpm run test
running unit tests viaPhantomJS
in a headless statenpm run lint
runningeslint
against your source (and config) filesnpm run build
runningwebpack
buildnpm run serve
serving thebuild/
folder contents
Whilst developing, you'll most likely to run npm run dev
in a terminal window, webpack
will take care of everything, bundling your project to an in-memory build/
folder and serving it from there. Also, npm run test
in another terminal window to see your tests running / failing on every file change.
If you'd like to see the output as files, just run npm run build
and the result will be found under a real build/
folder.