Git Product home page Git Product logo

hangman-the-game's Introduction

Hangman

Hangman is a web application in which the computer challenges the users to guess the word of its choice. The user is allotted six incorrect guesses before the computer wins. If the user guesses the word, the user wins. If you're eager to check out some of the functionality but don't want to start with a blank account, feel free to use the following:

  • username: zarazara
  • password: password

Built Using:

  1. Framework/Back-End: Ruby on Rails
  2. Front-End: HTML, CSS, Semantic UI framework
  3. Database: PostgreSQL
  4. Deployment: Heroku

Launch the web application:

  1. Zipped Folder
  • cd into the repository
  • install all dependencies
bundle install
  • open a server
rails server
  • open the local port specified (most likely localhost:3000)
  1. Check it out on Heroku

Minimum Viable Product (MVP):

  • Getting the word: Computer pings the Hangman Word API for the word
  • Displaying the secret word: Length of the secret word is displayed via underscores to the user
  • Selection of letter: User can select a letter to guess
  • Correct Selection: User will see the letter placed in its correct spot(s) in the word
  • Incorrect Selection: Letter will be placed in a separate box and the remaining guesses count will decrease by 1
  • User lost: User can make six incorrect guesses before the computer wins
  • User won: User guessed all the letters in the secret word before the six chances are up

Going beyond the MVP:

  • Difficulty Level: User can select a difficulty level based off how lucky they're feeling or how skilled they're are. Difficulty levels include easy, medium, hard, and surprise me.
  • Leaderboard: Members who have played at least one game are automatically added to the leaderboard. The board shows the top users by their win rates (games won / games played).
  • Friendship: Members can connect with other members via a friendship. This makes it easier for users to track how their friends are doing without skimming through the leaderboard.
  • First Aid: Members are given three bandaids when they sign up. They can use these bandaids as lifelines to restore one body part in the middle of the game
  • Hangman Display: Users can see the physical hangman diagram as they guess incorrectly
  • Quit Button: Users can quit in the middle of the game if they choose
  • Share Buttons: If a user wins a game, they can showcase their awesomeness by sharing a Tweet or a LinkedIn post.
  • Spotify: Who doesn't love to listen to upbeat music as they play word games? Spotify users have the capability to listen to music as they play
  • Tests: I wanted to practice test-driven development, so I implemented tests to check my models and routes before adding functionality to my controllers. I also wrote a few controller tests for additional testing practice.

Workflow:

  • I used an agile development approach when solving this problem
  • I decided early which tech stack I wanted to use
  • I mapped out what information my database would need to store along with what models, views, and controllers I would need
  • I created an outline of what my MVP would look like along with any additional features I wanted to add
  • I pseudocoded the algorithm of the actual hangman game
  • I set up my associations and my routes and began testing
  • I implemented one feature at a time before I moved on to the next
  • I created a seeds file and deployed to Heroku

Code Structure:

  • Models
  • I have three models: user, game, friendship
  • My User model sets the bcrypt method "has secure password", the association between games and friendships, and the validations needed upon sign up. There are also a few public methods that involve manipulating User object data that is called from the controllers.
  • My Game model sets the association to users and the validations needed to create a game. There are also a few public methods that involve manipulating Game object data that is called from the controllers.
  • My Friendship model sets the association to users. It practices self-referential associations.
  • Views
  • To make my code look cleaner and implement DRY, I created my view pages using partials.
  • Controllers
  • My users controller handles the displayment of the leaderboard, creating new users, assigning sessions id, creating friendships, and destroying friendships
  • My games controller handles the creation of a new game, updating each game when a user selects a letter, and deleting the game if one decides to leave mid-way
  • My sessions controller handles loggin in, logging out, and assigning sessions id

Hangman Word API

Hangman Word API is an API which returns back an array of word objects (JSON format). It can take two parameters (1) difficulty = integer between 0 and 10 (2) wordLength = integer

Built Using:

  1. Framework/Back-End: Express.js
  2. Database: MongoDb
  3. Deployment: Heroku

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.