diff --git a/sizebot/lib/errors.py b/sizebot/lib/errors.py index 1df04ad3..b705cd59 100644 --- a/sizebot/lib/errors.py +++ b/sizebot/lib/errors.py @@ -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." diff --git a/sizebot/lib/proportions.py b/sizebot/lib/proportions.py index eb1400e0..e3734e36 100644 --- a/sizebot/lib/proportions.py +++ b/sizebot/lib/proportions.py @@ -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: