Giter VIP home page Giter VIP logo

rps-game's Introduction

Rock - Paper - Scissor Game

To play the game

  • Step one: Clone the repo
    git clone https://github.com/jigmetnamgyal/rps-game.git
  • Step two: Install the gem
    bundle install
  • Step three: Create the database
    rails db:create
  • Ste four: Run the rspec
    rspec
  • Step five: Start the server
   rails s
  • Step Five: Open Postman or Altair and send the following request
    query {
        gameStart(userChoice: rock) {
            result
        }
    }
  • Expected Result:

Description

  • This is a small rock paper scissor game implemented in Ruby on Rails using GraphQL API and Faraday gem for 3rd party integration.

  • A user make a choice from Rock, paper and Scissor and compete with the crub bot

  • The application allow a user to choose rock, paper, or scissors

  • The application make a request to the external api to retrieve the server’s throw.

  • Error handling is done

  • If the api does not work or run out of time, an alternative of generating a random throw locally is handled by rescuing Faraday::ConnectionFailed

  • The application then respond with a result - whether the user won, lost or tied based on the server's throw

Rules

  • Rock beats scissors
  • Scissors beats paper
  • Paper beats rock
  • Identical throws tie (rock == rock, etc.)
  • Hammer beats all the other options. The rule for the hammer with the understanding that
    • hammer crushes rocks
    • hammer dulls scissor
    • hammer disproves paper
  • If we threw in any other as a choice, it will throw error and specify user that the input is invalid choice.

Technologies Used

  • GraphQL for API
  • Faraday to make external api request and error handling

Development and Testing

  • Pry for debugging
  • rspec-rails for unit testing
  • rubocop-rails and rubocop-rspec for code clean up
  • web-mock for stubbing 3rd part api for testing

rps-game's People

Contributors

jigmetnamgyal avatar

Stargazers

Roman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.