diff options
Diffstat (limited to 'data.py')
-rw-r--r-- | data.py | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -1,20 +1,20 @@ import random, math
class LevelData():
- def __init__(self):
- self.digits = []
- self.min_level = 1
- self.max_level = 5
- self.thresh_up = 6
- self.thresh_down = 0
- self.current_level = 1
- self.level_change = 0
- self.level_score = 0 - self.question_max = 6
- self.question_count = 0
- self.thresh_slider = 0
- self.thresh_mult = 2
- self.thresh_entry = 4 + def __init__(self): + self.question_max = 2 # number of questions in each section (slider, multiple choice & entry)
+ self.thresh_slider = 0 # if question count matches this number, change to this section
+ self.thresh_mult = self.question_max # if question count matches this number, change to this section
+ self.thresh_entry = 2 * self.question_max # if question count matches this number, change to this section
+ self.min_level = 1 # minimum levels in the activity; also the exponent of the current level
+ self.max_level = 5 # maximum levels in the activity; also the exponent of the current level
+ self.current_level = 1 # starting and current level indicator
+ self.question_count = 0 # number of questions asked on current level
+ self.level_score = 0 # number of questions correct on current level
+ self.thresh_up = 6 # level score at/above which the level will be increased
+ self.thresh_down = 0 # level score at/below which the level will be reduced
+ self.level_change = 0 # flag indicating a level change
+ self.digits = [] # collection of digits to create the question from random.seed()
def check_answer(self, response):
@@ -22,7 +22,7 @@ class LevelData(): self.level_score += 1
else:
self.level_score -= 1 - if self.question_count == self.question_max: + if self.question_count == self.question_max * 3: if self.level_score >= self.thresh_up and self.current_level < self.max_level:
self.level_change = 1
elif self.level_score <= self.thresh_down and self.current_level > self.min_level:
@@ -48,7 +48,8 @@ class LevelData(): elif self.level_change == -1: self.decrease_level()
self.question_count += 1
- # generate a random number. don't use digits 0 or 9; they cause duplicates in the mult choice answer set.
+ # generate a random number. don't use digits 0 or 9; + # they cause duplicates in the mult choice answer set.
self.digits = range(1,9)
random.shuffle(self.digits)
str_num = ""
@@ -73,7 +74,7 @@ class LevelData(): self.mult.append(int(math.ceil(self.random_number/(self.answer_decade*factor)) * self.answer_decade * factor))
def get_game_data(self):
- temp = "\nLevel: " + str(self.current_level)
+ temp = "\n\nLevel: " + str(self.current_level)
#temp += "\nRandom Number: " + str(self.random_number)
#temp += "\nDecade: " + str(self.answer_decade)
#temp += "\nCorrect Answer: " + str(self.correct_answer)
|