|
|
@@ -4,7 +4,7 @@ import random |
|
|
|
|
|
|
|
|
|
|
|
class Game: |
|
|
|
def __init__(self, teamsize=0): |
|
|
|
def __init__(self, teamsize=0, correct_field=0): |
|
|
|
self.teamsize = teamsize |
|
|
|
self.scoreboard = {'score_red': 0, |
|
|
|
'score_blue': 0, |
|
|
@@ -12,6 +12,8 @@ class Game: |
|
|
|
|
|
|
|
self.questions = QuestionDataBase('src_folder/BackEnd/Database/EinsZweiOderDrei.db') |
|
|
|
self.available_questions = list(range(1, self.questions.num_rows())) |
|
|
|
self.field = correct_field |
|
|
|
self.question = {} |
|
|
|
|
|
|
|
def set_teamsize(self, teamsize: int): |
|
|
|
self.teamsize = teamsize |
|
|
@@ -38,22 +40,20 @@ class Game: |
|
|
|
self.available_questions.remove(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'] |
|
|
|
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 |
|
|
|
self.set_correct_field(index) |
|
|
|
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 |
|
|
|
|
|
|
|
|