Esempio n. 1
0
   def __init__(self):
       QtGui.QDialog.__init__(self)
 
       # Set up the user interface from Designer.
       self.ui = Ui_Dialog()
       self.ui.setupUi(self)
       print dir(self.ui.listView)
       #self.ui.listView.setText('pippo')
       print questions.get_question(1).description 
Esempio n. 2
0
    def check_answer(self, answer, timeout, bonus):
        self.timeout = timeout
        if self.is_waiting_for_answer():
            if answer == questions.get_question(self.id_question_to_be_answered).answer and not self.is_timed_out():
                self.score += SCORE_CORRECT_ANSWER
                self.good_answers += 1
                if self.good_answers % CORRECT_ANSWERS_TO_BONUS == 0:
                    self.level += 1
                    self.level_up = True
                    if self.level % 3 == 0:
                        self.timer -= 1
                        if self.lifes < 6:
                            self.lifes += 1
            elif self.lifes > 1:
                self.lifes -= 1
            else:
                self.set_game_over(write_to_db=True)
                return False

            self.id_question_to_be_answered = -1
            self.question_number += 1
            if len(self.questions) == 0:
                self.set_game_over(write_to_db=True, game_complete=True)
            return True
        elif bonus != "":
            if self.special_question_enabled:
                self.score = self.score * int(bonus)
                self.level_up = False
                self.special_question_enabled = False
                self.timer = self.timer_temp
        else:
            self.set_game_over()
            raise QuestionsException
Esempio n. 3
0
 def get_question(self):
     if not self.is_over():
         if not self.is_waiting_for_answer():
             if self.level_up and len(self.special_questions) > 0:
                 self.special_question_enabled = True
                 self.timer_temp = self.timer
                 self.timer = SECONDS_FOR_QUESTION_SPECIAL
                 return questions.get_special_question(self.special_questions.pop(0))
             id_question = self.questions.pop(0)
             self.id_question_to_be_answered = id_question
             return questions.get_question(id_question)
         else:
             self.set_game_over()
             raise QuestionsException