From ed1c11267c95e4dcfff6061d5ff3a62e1c51691d Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 4 Apr 2022 01:37:57 +0200 Subject: [PATCH] =?UTF-8?q?Options:=20loudly=20crash=20if=20random=20text?= =?UTF-8?q?=20is=20not=20recognized,=20instead=20of=20de=E2=80=A6=20(#401)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Options: loudly crash if random text is not recognized, instead of defaulting to full "random" * Update Options.py Co-authored-by: Hussein Farran Co-authored-by: Hussein Farran --- Options.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Options.py b/Options.py index 9dd3525e..91211c4c 100644 --- a/Options.py +++ b/Options.py @@ -256,8 +256,10 @@ class Range(Option[int], int): return cls(int(round(random.triangular(random_range[0], random_range[1], random_range[1])))) else: return cls(int(round(random.randint(random_range[0], random_range[1])))) - else: + elif text == "random": return cls(random.randint(cls.range_start, cls.range_end)) + else: + raise Exception(f"random text \"{text}\" did not resolve to a recognized pattern. Acceptable values are: random, random-high, random-middle, random-low, random-range-low--, random-range-middle--, random-range-high--, or random-range--.") return cls(int(text)) @classmethod