|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Game: |
|
|
class Game: |
|
|
def __init__(self, teamsize=0): |
|
|
|
|
|
|
|
|
def __init__(self, teamsize=0, correct_field=0): |
|
|
self.teamsize = teamsize |
|
|
self.teamsize = teamsize |
|
|
self.scoreboard = {'score_red': 0, |
|
|
self.scoreboard = {'score_red': 0, |
|
|
'score_blue': 0, |
|
|
'score_blue': 0, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.questions = QuestionDataBase('src_folder/BackEnd/Database/EinsZweiOderDrei.db') |
|
|
self.questions = QuestionDataBase('src_folder/BackEnd/Database/EinsZweiOderDrei.db') |
|
|
self.available_questions = list(range(1, self.questions.num_rows())) |
|
|
self.available_questions = list(range(1, self.questions.num_rows())) |
|
|
|
|
|
self.field = correct_field |
|
|
|
|
|
self.question = {} |
|
|
|
|
|
|
|
|
def set_teamsize(self, teamsize: int): |
|
|
def set_teamsize(self, teamsize: int): |
|
|
self.teamsize = teamsize |
|
|
self.teamsize = teamsize |
|
|
|
|
|
|
|
|
self.available_questions.remove(random_question_number) |
|
|
self.available_questions.remove(random_question_number) |
|
|
|
|
|
|
|
|
question= list(questions_data[random_question_number]) |
|
|
question= list(questions_data[random_question_number]) |
|
|
data = dict(zip(field_names, question)) |
|
|
|
|
|
add_data = my_game.correct_field(data) |
|
|
|
|
|
return add_data |
|
|
|
|
|
|
|
|
|
|
|
def correct_field(self, data_dict: dict) -> dict: |
|
|
|
|
|
|
|
|
self.question = dict(zip(field_names, question)) |
|
|
|
|
|
self.add_correct_field() |
|
|
|
|
|
return self.question |
|
|
|
|
|
|
|
|
|
|
|
def add_correct_field(self): |
|
|
answeroption = ['Answeroption_1', 'Answeroption_2', 'Answeroption_3', 'Correct_answeroption'] |
|
|
answeroption = ['Answeroption_1', 'Answeroption_2', 'Answeroption_3', 'Correct_answeroption'] |
|
|
for i in range(0, len(answeroption) -1): |
|
|
for i in range(0, len(answeroption) -1): |
|
|
if data_dict[answeroption[-1]] == data_dict[answeroption[i]]: |
|
|
|
|
|
|
|
|
if self.question[answeroption[-1]] == self.question[answeroption[i]]: |
|
|
index = answeroption.index(answeroption[i]) + 1 |
|
|
index = answeroption.index(answeroption[i]) + 1 |
|
|
|
|
|
self.set_correct_field(index) |
|
|
break |
|
|
break |
|
|
data_dict.update([('Correct_field', index)]) |
|
|
|
|
|
return data_dict |
|
|
|
|
|
|
|
|
self.question.update([('Correct_field', index)]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my_game = Game() |
|
|
|
|
|
test = my_game.get_question() |
|
|
|
|
|
|
|
|
def set_correct_field(self, correct_field: int): |
|
|
|
|
|
self.field = correct_field |
|
|
|
|
|
|
|
|
|
|
|
|