This commit is contained in:
Collin R
2020-02-01 00:48:14 -08:00
parent 3dee25bd80
commit 5b3a3d8f1f
4 changed files with 32 additions and 61 deletions

View File

@@ -8,24 +8,10 @@ Level = namedtuple('Level', 'name points')
# A ([Level], Level, Level) tuple;
# previous can be empty, and exactly one of current and next can be None
LevelInfo = namedtuple('LevelInfo', 'previous current next')
# LevelInfo = namedtuple('LevelInfo', 'prev cur next')
### Functions ###
"""
def get_levels(config):
levels = []
for opt in config.options('Levels'):
name, points = opt.title(), config.getint('Levels', opt)
levels.append(Level(name, points))
# levels.append((opt.title(), config.getint('Levels', opt)))
# levels.sort(key=lambda pair: pair[1])
levels.sort(key=lambda lvl: lvl.points)
return levels
"""
def user_level_info(points, levels):
'''Return a tuple the user's previous (plural), current, and next levels.
@@ -56,11 +42,3 @@ def is_max_level(level_info):
return not level_info.next
"""
def is_max_level(points, levels):
'''Assume levels is sorted in ascending order by points.'''
# return points >= levels[-1][1]
return points >= levels[-1].points
"""