diff --git a/Generate.py b/Generate.py index 763471e9..f048e543 100644 --- a/Generate.py +++ b/Generate.py @@ -455,7 +455,7 @@ def handle_option(ret: argparse.Namespace, game_weights: dict, option_key: str, else: player_option.verify(AutoWorldRegister.world_types[ret.game], ret.name, plando_options) else: - setattr(ret, option_key, option(option.default)) + setattr(ret, option_key, option.from_any(option.default)) # call the from_any here to support default "random" def roll_settings(weights: dict, plando_options: PlandoSettings = PlandoSettings.bosses): diff --git a/Options.py b/Options.py index 11ec46f2..49f044d8 100644 --- a/Options.py +++ b/Options.py @@ -483,7 +483,7 @@ class Range(NumericOption): if text.startswith("random"): return cls.weighted_range(text) elif text == "default" and hasattr(cls, "default"): - return cls(cls.default) + return cls.from_any(cls.default) elif text == "high": return cls(cls.range_end) elif text == "low": @@ -494,7 +494,7 @@ class Range(NumericOption): and text in ("true", "false"): # these are the conditions where "true" and "false" make sense if text == "true": - return cls(cls.default) + return cls.from_any(cls.default) else: # "false" return cls(0) return cls(int(text)) @@ -698,10 +698,7 @@ class OptionSet(Option[typing.Set[str]], VerifyKeys): @classmethod def from_any(cls, data: typing.Any): - if type(data) == list: - cls.verify_keys(data) - return cls(data) - elif type(data) == set: + if isinstance(data, (list, set, frozenset)): cls.verify_keys(data) return cls(data) return cls.from_text(str(data))