Reason for this Game
Games like Trivial Pursuit made playing trivia games great fun with you and your friends. Some organizations use this game as a money-generating activity and a lot of groups attend hoping to win prizes. More recently, trivia games are being used in restaurants and in classrooms through apps that the players use connecting to a centralized game.
This final programming project will build the foundation of the Trivia Game Engine needed to run these bigger applications. By “engine”, it is expected that the code for this can be used in a module as part of a bigger application and this project will provide the necessary functions to use this many times over.
Rules of the Game
The expectations of running this game are that the user will select a category they want to try. The system will load that category from a file, parse out the content, and start the game. For each question in the category, the question and four possible answers will be displayed on the screen. The application will accept the user’s choice of the four options and only one of those options. The application will then determine if the choice made was correct or not and present a message to the user of the validity of their selection. The application will also keep a running tally of the user’s score throughout this game. At the end of all of the questions, the user will be presented with their final score and presented with a message of the quality of their score. Score comments are to be presented as follows:
90% and greater: “Awesome Job!”
80% to less than 90%: “Good work!”
70% to less than 80%: “Well, you tried.”
60% to less than 70%: “You may want to read more and put down the phone.”
After the category, the user should be presented with the menu of categories again. One of the options on this screen should be “Quit”. If the user selects to quit, the program will stop.
Your assignment is to build this game. All of the work you have done to this point will cover all of the requirements of this game, but you will have to take it a step at a time to put it all together. For this assignment, this game is a TEXT-based game. However, it should still present well for the user to understand that they are answering a new question or that they are in the menu of category choices. Here is an example of what this could look like,, with user input in bold:
Additionally, the structure of your program should allow it to be used as a module. While this sounds daunting, it really means following these four rules:
All functionality that runs this application (loading the category content, running the game, displaying results, etc.) should all be isolated in functions using parameters and return values to handle the functionality.
No data will be kept in the global scope. That is, no variables will be defined indented to the far left.
Using a main() function to run the application will provide the “glue” that pulls together these features into a complete game.
The call to the main function needs to be guarded to prevent it from being called automatically when referenced through an import statement. This is a new concept being introduced here, but just follow the syntax:
if __name__ == “__main__”:
If you wish to attempt these, it is suggested that you only do so after the primary goals have been met.
[10 pts] To add some variety to the game, provide a random phrase function for successful and unsuccessful results of the question. These can be funny but MUST be clean and not offensive. An example of an unsuccessful response: “Really? Did you read the question?” or “Um, yea.. no!” These should be selected at random and there should be enough phrases to get through a 10 question category.
[20 pts] Run this application on a graphic screen. This sounds very complex, but at a minimum, it is presenting text, getting mouse clicks from the selected choice, and clearing the screen. It is recommended that this be done in a separate .py file and use the main submission as an import.