Skip to content

Commit

Permalink
maybe kill it after a while?
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiDuncan committed Nov 26, 2023
1 parent df7335f commit d0bf4b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sizebot/lib/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,13 @@ def formatMessage(self):

def formatUserMessage(self):
return f"Could not parse {self.s} into a {self.t}."

class UnfoundStatException(DigiException):
def __init__(self, s) -> None:
self.s = s

def formatMessage(self):
return f"Could not calculate the {self.s} stat."

def formatUserMessage(self):
return f"Could not calculate the {self.s} stat."
4 changes: 4 additions & 0 deletions sizebot/lib/proportions.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,17 @@ def __init__(self, user: User, stats: list[StatValue] = None):
self.stats.append(sv)
found_stats[sv.stat.sets] = sv.value
# FInd the everything else
loops = 0
while len(all_stats) != len(found_stats):
loops += 1
for s in all_stats:
if s.sets not in found_stats:
if all([r in found_stats for r in s.requires]):
sv = s.set(self.user, found_stats)
self.stats.append(sv)
found_stats[sv.stat.sets] = sv.value
if loops >= 10:
raise errors.UnfoundStatException([s.name for s in all_stats if s.sets not in found_stats])

@property
def scaled(self) -> StatBox:
Expand Down

0 comments on commit d0bf4b2

Please sign in to comment.