Skip to content

Commit

Permalink
[#44] Err handle for empty scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
jrsmth-tier2 committed Apr 10, 2024
1 parent b0ffddf commit 7433f7e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/model/group/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ def dethrone(self):
def __is_unworthy(self, new_streak):
""" Determine if streak is unworthy of scroll update by comparison to the lowest record """
sorted_scroll = sorted(self.scroll, key=lambda x: x.streak, reverse=False)
return new_streak < sorted_scroll[0].streak
return len(sorted_scroll) == 0 or new_streak < sorted_scroll[0].streak

def __is_active(self, streak_id):
""" Determine if player streak is active in scroll by comparison with recorded streak ids """
matching_ids = [x for x in self.scroll if x.streak_id == streak_id]
return len(matching_ids) != 0
if len(self.scroll) != 0:
matching_ids = [x for x in self.scroll if x.streak_id == streak_id]
return len(matching_ids) != 0
else: return False

0 comments on commit 7433f7e

Please sign in to comment.