Coder Social home page Coder Social logo

hangman's Introduction

This app is a Hangman Game. An important feature of our version of hangman is that instead of just playing one word at a time, you continue to play more and more words until you fail to guess one of them, and therefore die. A "game" of hangman then is one round of continuous words until you either exit or die. You get an accumulated score based on the total of the point values of each word that you correctly guessed in that game.

There are four models:

  • Player, who has_many:
  • Games, which each have many:
  • Words, through:
  • Gamewords, a joiner for the previous two.

A word technically "has_many:" Games, but we don't care about that because there is never a time where we care about checking which games a given word was used in.

The hangman.rb file will take care of all of the running and menus and CLI interaction.

There is also a file hangman_picture.rb which is basically just an array of the different ASCII hangman doodle images, and a method to return the appropriate doodle for your stage in the game.

A Word object has just a string "the_word" of the actual word itself, as well as a float point-value, which is arbitrarily based on the difficulty of guessing that word.

Through GameWords, a Game instance can access all the words used in that game. GameWords serves no other purpose.

A Player instance has methods for getting their top score, all their past scores, deleting one or all of their past scores, and viewing the number of games they have played so far.

The Game class is where nearly all of the non-CLI magic happens. The Game class can give you the leaderboard of the all-time high scores in our database. A Game instance can calculate its score, retrieve a new word object, check a one-letter-guess or a whole-word-guess against the current word, keep track of any hints used, generate hints, create and update the concealed word (with letters obscured), keep track of what you have guessed already, and check if you have completed the whole word.

Then the Hangman.rb file adds all of the actual interaction features. Here, you can log in or sign up, start a new game, update your username, view scores, and delete scores. Inside of a game, you can guess letters, words, and choose to receive hints. As you do these things, the terminal is updated with sounds depending on the result of your guess, and an updated score, word, and doodle.

Some future developments could be:

  • to allow a player to continue a game that they exited from and didn't die in yet.
  • to award bonus points for guessing a whole word "early" (while there is more than one letter left)
  • add more words
  • have words calculate their own point value based on pre-set criteria for assessing their own difficulty

hangman's People

Contributors

zacharydagnall avatar samferebee 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.