A simple Rock Paper Scissors Game, with easily extendable game modes.
- React
- Vite
- Typescript
- TailwindCSS
- Jest
Latest stable versions of Chrome, Firefox, Edge, and Safari. Mobile and Desktop.
The game logic is seperated from the UI Layer into the useGame
hook. The Game is basically seperated into 5 stages.
config
Choose a config viasetConfig
player1Picking
Player 1 chooses an action viapickAction
player2Picking
Player 2 chooses an action viapickAction
showdown
Wait until winner is determined viadetermineWinner
reveal
Reveal Winner and save game to history
resetGame
puts you back at stage 2
resetConfig
puts you back at stage 1
All Configurations are in the config
folder.
The different actions a player can take, and which action beats which, are defined here. These can be easily extended beyond Rock, Paper and Scissors (see lizardSpockExtension
).
The different kinds of Players and how they pick an action are defined here.
computer
picks it by random.
human
gets prompted the HumanPickingStage
and picks from there.
A possible extension might be a smart ai with strategies or even an online human opponent.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in your browser.
Runs the Jest tests.
Tests and builds for production, outputs by default to the dist
folder.
After you have built the app, you can locally preview the production build with this command.
- add more tests (this is my first time trying out Jest)
- save actions in the game history only by reference, right now a lot of unnecessary, duplicate data gets saved in local history
- make useGame more robust, if the triggers for the next stages get called out of order, it will probably cause bugs
- make the game more "playful" (animations, sounds, etc.)
- add a tutorial
- add a full viewable history
This project is licensed under the MIT License - see the LICENSE.md file for details