Skip to content

splendorklein/app-engine-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Full Stack Nanodegree Project 4

Set-Up Instructions:

  1. Update the value of application in app.yaml to the app ID you have registered in the App Engine admin console and would like to use to host your instance of this sample.
  2. Run the app with the devserver using dev_appserver.py DIR, and ensure it's running by visiting the API Explorer - by default localhost:8080/_ah/api/explorer.

##Game Description: Hangman is a paper and pencil guessing game. The player tries to guess a word, phrase or sentence by suggesting letters or numbers, within a certain number of guesses. This app is a simple implementation of Hangman. The word to guess is represented by a row of stars, representing each letter of the word. If the player suggests a letter which occurs in the word, the app reveals it in all its correct positions. If the suggested letter or number does not occur in the word, the player loses one attempt.

##Score Keeping: Your score = 14 + the length of the word - attempts remainning Which means allowing yourself with less attempts when start a new game enables you to get a higher score.

##How to play:

  • Create a new user, using the create_user endpoint. Remember to copy the urlsafe_key
    property.
  • Use create_game to create a game.
  • Use make_move to make a guess. You can quess one letter or the whole word each time.

##Files Included:

  • api.py: Contains endpoints and game playing logic.

  • app.yaml: App configuration.

  • cron.yaml: Cronjob configuration.

  • main.py: Handler for taskqueue handler.

  • models.py: Entity and message definitions including helper methods.

  • utils.py: Helper function for retrieving ndb.Models by urlsafe Key string.

  • word.py: Dictionary for the game. ##Endpoints Included:

  • create_user

    • Path: 'user'
    • Method: POST
    • Parameters: user_name, email (optional)
    • Returns: Message confirming creation of the User.
    • Description: Creates a new User. user_name provided must be unique. Will raise a ConflictException if a User with that user_name already exists.
  • new_game

    • Path: 'game'
    • Method: POST
    • Parameters: user_name, attempts(maximum is 14)
    • Returns: GameForm with initial game state.
    • Description: Creates a new Game. user_name provided must correspond to an existing user - will raise a NotFoundException if not. Also adds a task to a task queue to update the average moves remaining for active games.
  • get_game

    • Path: 'game/{urlsafe_game_key}'
    • Method: GET
    • Parameters: urlsafe_game_key
    • Returns: GameForm with current game state.
    • Description: Returns the current state of a game.
  • make_move

    • Path: 'game/{urlsafe_game_key}'
    • Method: PUT
    • Parameters: urlsafe_game_key, guess
    • Returns: GameForm with new game state.
    • Description: Accepts a 'guess' and returns the updated state of the game. If this causes a game to end, a corresponding Score entity will be created.
  • get_scores

    • Path: 'scores'
    • Method: GET
    • Parameters: None
    • Returns: ScoreForms.
    • Description: Returns all Scores in the database (unordered).
  • get_user_scores

    • Path: 'scores/user/{user_name}'
    • Method: GET
    • Parameters: user_name
    • Returns: ScoreForms.
    • Description: Returns all Scores recorded by the provided player (unordered). Will raise a NotFoundException if the User does not exist.
  • get_user_games

    • Path: 'game/user/{user_name}'
    • Method: GET
    • Parameters: user_name
    • Returns: GameForms.
    • Description: Returns all of a User's active games.
  • cancel_game

    • Path: 'game/cancel/{urlsafe_game_key}'
    • Method: POST
    • Parameters: urlsafe_game_key
    • Returns: StringMessage.
    • Description: Cancels a game in progress.
  • get_high_scores

    • Path: 'hightscores'
    • Method: GET
    • Parameters: limit
    • Returns: ScoreForms.
    • Description: Generates a list of high scores in descending order.
  • get_user_rankings

    • Path: 'user/rankings'
    • Method: GET
    • Parameters: None
    • Returns: UserForms.
    • Description: Returns players' ranking by their performance.
  • get_game_history

    • Path: 'game/{urlsafe_game_key}/history'
    • Method: GET
    • Parameters: urlsafe_game_key
    • Returns: MovesForm
    • Description: Returns a single game's history.

##Models Included:

  • User

    • Stores unique user_name and (optional) email address.
  • Game

    • Stores unique game states. Associated with User model via KeyProperty.
  • Score

    • Records completed games. Associated with Users model via KeyProperty.

##Forms Included:

  • GameForm
    • Representation of a Game's state (urlsafe_key, attempts_remaining, game_over flag, message, user_name).
  • NewGameForm
    • Used to create a new game (user_name, min, max, attempts)
  • MakeMoveForm
    • Inbound make move form (guess).
  • ScoreForm
    • Representation of a completed game's Score (user_name, date, won flag, guesses).
  • ScoreForms
    • Multiple ScoreForm container.
  • StringMessage
    • General purpose String container.
  • UserForm
    • User information container.
  • UserForms
    • Users ranking container.
  • MovesForm
    • Game history container.
  • GameForms
    • Multiple GameForm container.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages