diff --git a/Options.py b/Options.py index 47f4b1d45c..ed19d2eb87 100644 --- a/Options.py +++ b/Options.py @@ -938,26 +938,27 @@ class OptionCounter(OptionDict): min: int | None = None max: int | None = None cull_zeroes: bool = False + value: collections.Counter[str] def __init__(self, value: dict[str, int]) -> None: - cleaned_dict = {} + cleaned_dict = collections.Counter() invalid_value_errors = [] - for key, value in value.items(): - if not isinstance(value, (int, float)) or int(value) != value: - invalid_value_errors += [f"Invalid value {value} for key {key}, must be an integer."] + for key, subvalue in value.items(): + if not isinstance(subvalue, (int, float)) or int(subvalue) != subvalue: + invalid_value_errors += [f"Invalid value {subvalue} for key {key}, must be an integer."] continue - if self.cull_zeroes and value == 0: + if self.cull_zeroes and subvalue == 0: continue - cleaned_dict[key] = int(value) + cleaned_dict[key] = int(subvalue) if invalid_value_errors: type_errors = [f"For option {self.__class__.__name__}:"] + invalid_value_errors - raise TypeError("\n".join(invalid_value_errors)) + raise TypeError("\n".join(type_errors)) - super(OptionCounter, self).__init__(collections.Counter(cleaned_dict)) + self.value = cleaned_dict def verify(self, world: type[World], player_name: str, plando_options: PlandoOptions) -> None: super(OptionCounter, self).verify(world, player_name, plando_options)