For homework two, you’ll be working from the two examples we built in class to create a site that responds to user input. To get started, take a look at the rules of the game Mastermind: http://en.wikipedia.org/wiki/Mastermind_(board_game). Build a version of Mastermind that allows the user to guess at a combination, and keeps track of each previous guesses by displaying them on the page using visual cues (the color of text) to show a right letter in the wrong place or a right letter in the right place.
- Generating the combination for the player to guess
- Reading in the player’s guess and checking letter by letter (using loops to compare the character in each spot)
- Outputting the guess to the browser (using an appended element, see pg 99)
- Showing the player an alert message when they successfully win the game
- A-Level Work: Build a working mastermind game that accurately responds to both a right letter in the wrong place and a right letter in the right place. Show the player’s guesses with clear visual cues, in some format appropriate to the game. End the game when the player guesses correctly. Handle inappropriate user guesses by prompting them to try again (if the guess is too long or has incorrect characters) Add at least one extended functionality, such as: a high score table (based on number of guesses), the ability for the player to provide the code for someone else to guess (in imitation of a “two player” mode), or the option to play again without refreshing the browser.
- B-Level Work: Build a working mastermind game that accurately responds to both a right letter in the wrong place and a right letter in the right place. Show the player’s guesses with clear visual cues, in some format appropriate to the game. Should respond to victory, but might not include the ability to reset without reloading the browser.
- C-Level Work: Create a basic version of the game that is playable, but may not respond properly to user hits or misses. Should successfully handle the victory condition.
- D-Level Work: Mastermind is attempted but fails to compile due to errors in coding. The base of the scripting is present but not functional.
- Failing Work: Project is not submitted or demonstrates no attempt to complete the task.