Skip to content

OlyErofeeva/rpsls-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

26 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ–– Rock Paper Scissors Lizard Spock (RPSLS) Game

Inspired by The Big Bang Theoryโ€™s twist on Rock-Paper-Scissors ๐Ÿ––

๐Ÿงฉ Project Structure

  • Frontend: React with TypeScript
  • Backend: Node.js with Express

๐Ÿš€ Features

  • Play Rock-Paper-Scissors-Lizard-Spock against a computer opponent
  • See the results of the 10 recent games on the scoreboard
  • Reset the scoreboard if desired
  • Get motivational messages when losing or on a win streak
  • The app supports desktop, tablet & mobile resolutions

๐ŸŽฎ Game Rules

  • ๐Ÿชจ Rock crushes Lizard & Scissors
  • ๐Ÿ“œ Paper covers Rock & disproves Spock
  • โœ‚๏ธ Scissors cuts Paper & decapitates Lizard
  • ๐ŸฆŽ Lizard poisons Spock & eats Paper
  • ๐Ÿ–– Spock smashes Scissors & vaporizes Rock

๐Ÿ“ธ Screenshots

image

Tablet Mobile
image image

โš™๏ธ Technical Details

  • Overall approach: tried to use a minimum of additional libraries
  • A 4-pixel grid was used for the UI design
  • Scoreboard data is stored in local storage
  • To calculate the random choice of the computer was used https://codechallenge.boohma.com/random endpoint
  • There is the /choice endpoint, but it's not used on frontend

๐Ÿ› ๏ธ Getting Started via ๐Ÿณ Docker

Prerequisites

  • Docker & Docker Compose
  • Make sure nothing is running on ports 3000 and 5173
docker-compose up --build

The frontend runs by default on http://localhost:5173. The backend runs by default on http://localhost:3000.

๐Ÿ› ๏ธ Getting Started (without using Docker)

Prerequisites

  • Node.js (>= 24.x)
  • npm

Backend Setup

cd backend
npm install
npm run dev

The backend runs by default on http://localhost:3000.

Frontend Setup

cd frontend
npm install
npm run dev

The frontend runs by default on http://localhost:5173.

๐Ÿ“ก API Endpoints

Method Endpoint Description
GET /choices Get a list of player's options
GET /choice Get a randomly generated choice
POST /play Submit a move and get result
Example Messages

/choices example Response:

[
    {
        "id": 1,
        "name": "rock"
    },
    {
        "id": 2,
        "name": "paper"
    },
    {
        "id": 3,
        "name": "scissors"
    },
    {
        "id": 4,
        "name": "lizard"
    },
    {
        "id": 5,
        "name": "spock"
    }
]

/choice example Response:

{
  "id": 5,
  "name": "spock"
}

/play example Payload:

{
  "player": 1
}

/play example Response

{
  "player": "1",
  "computer": "2",
  "results": "lose"
}

About

๐Ÿ–– Rock Paper Scissors Lizard Spock game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published