Options: loudly crash if random text is not recognized, instead of de… (#401)

* Options: loudly crash if random text is not recognized, instead of defaulting to full "random"

* Update Options.py

Co-authored-by: Hussein Farran <hmfarran@gmail.com>

Co-authored-by: Hussein Farran <hmfarran@gmail.com>
This commit is contained in:
Fabian Dill 2022-04-04 01:37:57 +02:00 committed by GitHub
parent a3e1ac896f
commit ed1c11267c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -256,8 +256,10 @@ class Range(Option[int], int):
return cls(int(round(random.triangular(random_range[0], random_range[1], random_range[1])))) return cls(int(round(random.triangular(random_range[0], random_range[1], random_range[1]))))
else: else:
return cls(int(round(random.randint(random_range[0], random_range[1])))) 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)) 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-<min>-<max>, random-range-middle-<min>-<max>, random-range-high-<min>-<max>, or random-range-<min>-<max>.")
return cls(int(text)) return cls(int(text))
@classmethod @classmethod