-
-
Save N0RT0/3510a3cf266fbb23167ad176025d8ba7 to your computer and use it in GitHub Desktop.
Trivia Player Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import pygame | |
| import pygame_menu | |
| import categories | |
| class Player(): | |
| # List used for selector object | |
| CATEGORIES = [('English / Language Arts',0), | |
| ('Science',1), | |
| ('Social Studies',2), | |
| ('Math',3), | |
| ('Computer Science',4), | |
| ('Nature and Wildlife',5)] | |
| # Category_translator is used to read back the settings that the user chose | |
| CATEGORY_translator = {'English / Language Arts':categories.English_Language_Arts, | |
| 'Science':categories.Science, | |
| 'Social Studies':categories.Social_Studies, | |
| 'Math':categories.Math, | |
| 'Computer Science':categories.Computer_Science, | |
| 'Nature and Wildlife':categories.Nature_Wildlife} | |
| def __init__(self,index): | |
| self.CATEGORY = "" | |
| self.score = 0 | |
| self.questions = [] | |
| self.has_questions = False | |
| self.question_pool_index = index-1 | |
| self.choice_index = 0 | |
| def shuffle_choices(self,choices:list) -> list: | |
| random.shuffle(choices) | |
| return choices | |
| def get_question_pool(self): | |
| question_pool = self.CATEGORY_translator[self.CATEGORY] | |
| random.shuffle(question_pool) | |
| self.has_questions = True | |
| return question_pool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment