From d0bf4b28556b3d7b5b5a73345251cd30f4c67ab3 Mon Sep 17 00:00:00 2001 From: DigiDuncan Date: Sun, 26 Nov 2023 18:02:35 -0500 Subject: [PATCH] maybe kill it after a while? --- sizebot/lib/errors.py | 10 ++++++++++ sizebot/lib/proportions.py | 4 ++++ 2 files changed, 14 insertions(+) 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: