예제 #1
0
 def play_round(self, number_of_rounds, question_generator):
     score = 0
     total = 0
     os.system('cls' if os.name == 'nt' else 'clear')
     for _ in range(number_of_rounds):
         question_generator()
         self.game.start_timing()
         try:
             user_input = self.get_user_input_for_question(self.game.current_question.query,
                                                           [TerminalController.QuestionAction.QUIT,
                                                            TerminalController.QuestionAction.SAVE])
         except InterruptInputException as e:
             if e.msg == TerminalController.QuestionAction.QUIT:
                 print("Returning to main menu.")
                 return score, total
             elif e.msg == TerminalController.QuestionAction.SAVE:
                 self.game.save_current_question()
         self.game.end_timing()
         outcome, correct_value, time_taken = self.game.solve_question(user_input)
         if config.getboolean("General", "SHOW_TIMER"):
             print("Time taken:" + str(time_taken))
         total += 1
         if outcome:
             score += 1
             print("Correct!")
         else:
             print("Wrong, correct value is %i" % correct_value)
         if config.getboolean("General", "PAUSE_AFTER_QUESTION"):
             user_input = input("Enter any key to continue. S to save the question, Q to quit")
             if str.isalpha(user_input):
                 if TerminalController.QuestionAction.SAVE.value == user_input:
                     self.game.save_current_question()
                 elif TerminalController.QuestionAction.QUIT.value == user_input:
                     return score, total
     return score, total
예제 #2
0
def is_debug_mode():
    return config.getboolean("Debug","Mode")