Throughout the world's history, there have been many influential people who have left behind their wisdom and thoughts, which are often expressed in quotes. These quotes have been passed down from generations to generations, typically through family teachings or schools, as valuable guidance and life principles for future generations. Unfortunately, todays children lack exposures to these valuable quotes in their early education, despite better accessibility to internet nowadays compared to years before. Instead, children spend more time on games, movies, or other forms of entertainment.
William, a researcher in the area of early education, wants to bring in the wisdoms and thoughts from influential people to the children's educations curriculum. He has an idea of creating an educational game that imparts influential quotes to the children as they play the game. He called this game Quote Quest and has drafted the requirements for this game. He needs someone to write a simple prototype for this game in Python programming language.
You are to develop the Quote Quest game using Python based on Problem Description and Program Requirements below
You should find a folder named Starter Kit in the same folder as this document. This folder contains files that help you kick start your assignment. Here are the files in the folder:
1. quotes.txt
This file contains a list of quotes from which the game will choose. Each line contains a single quote. You can add new quotes to this file, if you wish.
2. psphelper.py
This Python source code contains some helpful functions that you can use in your program. Check out the documentation of each function to know what they do. You don't have to modify this file at all.
3. QuoteQuest.py
This Python source code demonstrates how to use the functions in psphelper.py. You may use this quote as a starting point for your program, but make sure you code conforms to the requirements in Source Code Requirements, Deliverables, and Submission Instructions.
4. game.exe_rename
This is actually an executable for the game. It is given for your reference. To run it, kindly rename it to game.exe, open command prompt at the executable's location, and type game. Please ensure that quotes.txt file is in the same folder as this executable, otherwise it will have error.
Here are the general descriptions about the game to be developed for this assignment.
1) Quote Quest is a 2-player turn-based game in which players solve quote puzzles to win money.
2) Each game has a blank quote puzzle, with each blank representing an alphabet in the quote. Punctuation is revealed as needed.
3) The goal of the game is to earn money while solving the puzzle. The player who earns the most is declared the winner.
4) The players are allowed to perform three operations during the game: solve the puzzle, buy a vowel, and guess a consonant. They earn money by solving the puzzle and guessing consonants correctly, while they spend money by buying vowels.
5) To solve the puzzle, the player needs to enter his solution. If his solution is correct, the quote is revealed, the player's money is doubled, and the winner is declared before the game ends. Otherwise, the player loses his turn to the other player.
6) To buy a vowel, the player needs to enter the vowel to buy. If the vowel exists, all existences of the vowel in the quote are revealed, provided that the player has sufficient money to buy. In the case where the player has insufficient money, the player still maintains his turn and can play. However, if the vowel does not exist, the player loses his turn to the other player. Each vowel costs RM200.
7) To guess a consonant, the player needs to enter the consonant to guess. Then, a dice is rolled to determine the prize per consonant the player would get if his guess is correct. If the consonant exists, all existences of the consonant in the quote are revealed, and the player earns prizes based on the rolled prize and the number of such consonants in the quote. If the consonant does not exist, the player loses his turn to the other player. This is the only operation where dice is rolled.
8) Note that the dice is an octahedron (i.e. a 3D shape with 8 faces) and therefore has 8 values: RM500, RM 600, RM 700, RM 800, RM 900, RM1000, Bankrupt, and Lose A Turn. Both "Bankrupt" and Lose A Turn forfeit the player's turn, with Bankrupt also eliminating the money the player has earned so far.
9) The player gets to maintain his turn (i.e. perform any operations any number of times ) unless he gets into any situations mentioned in item (5) to (8) that causes him to lose his turn.
10) The game ends when the puzzle is completely solved by any player.
Here are the requirements that your program must satisfy to get FULL marks. You should read this while running game.exe for better understanding.
(A) Interface and Appearance
1) Main Interface
The Main interface is always shown at the top of the command prompt. It contains several parts: Game Title, Quote Screen, Money Screen, Input Options, Current Player, and Input Prompt.
(a) Quote Screen: This part shows the blank quote puzzle in which underscore indicates a hidden letter.
(b) Money Screen: This part shows the money each player has earned so far.
(c) Input Prompt: This part waits for player's input.
(B) Program Logic
1) Initially, the game loads a list of quotes from a text file named quotes.txt to a list variable. Then, a quote is randomly selected from the list variable for the quote puzzle. This is followed by the display of Main Interface before the game begins. [HINTS: Check out QuoteQuest.py , one of the starter kit codes, for help.]
2) To play the game, the player chooses which operation to perform according to Input Options. The valid input is either an alphabet (regardless of letter case) or a forward slash (/). If the player enters any input that is invalid, an error message is shown to indicate the input is invalid. The player is allowed to enter an input again until the input is valid.
3) If player enters a forward slash (/), the player will be prompted to enter his solution to the puzzle. The solution entered must be similar to the quote (including punctuations, if any), except for the letter case. If the solution is correct, the player's money is doubled and the game ends. This is followed by the requirement stated in item (9) below. If the solution is wrong, a message indicating so is shown. The player will lose its turn for the other player to play.
4) If the player enters a vowel, this means he intends to buy a vowel. The game will first check whether the vowel entered has been taken before (i.e. appears in Quote Screen). If so, the game informs the player about it and the player is allowed to input again.
5) If the vowel is not already in Quote Screen, then the game will check the vowel's existence in the quote and count its occurrence. If the vowel does not exist in the quote, the game will inform the player about it, and the player loses his turn.
6) However, if the vowel exists, the game will calculate the cost of buying the vowel, which is the number of its occurrence multiplied by RM200 (i.e. price per vowel). Then, the game will check if the player has sufficient money to cover the cost. If so, the player's money is deducted by the cost to buy the vowel, and the game will display the vowels number of occurrence and the cost the player has spent to buy the vowel. If the player does not have sufficient money, the game will inform the player that he has insufficient money to buy the vowel. In either case, the player does not lose his turn and therefore can continue play.
7) If the player enters a consonant, it means he intends to guess a consonant. Similar to the cases for vowel, the game will first check whether the consonant has been taken, and also whether the consonant exists. The game handles the events of consonant being taken and of consonant does not exists in the same way as those for vowel, stated in item (4) and (5).
8) If the consonant exists, then the game will determine the prize per consonant by rolling the dice mentioned in item (8) of Problem Description. If the dice value is an amount in RM, the total amount earned by the player is the consonant's number of occurrence multiplied by the dice value. The game will show the dice value, the consonants number of occurrence, and the total amount earned by the player. If the dice value is "Bankrupt" or Lose a turn, the player will lose his turn, with Bankrupt also resets the players money to zero.
9) The game continues to run, with the screen of the command prompt cleared for new input to be entered. The game will only ends when a player has correctly solved the puzzle, either though guessing the last available alphabet correctly or solving the puzzle correctly.
When the game ends, it will show Quote Screen revealing all hidden letters in the quote, the players' money, and the winner. The winner is determined by the player with the highest amount of money. If both players have the same money, it is considered a tie.