-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rules: Verify the default values of Option
s.
#2403
Conversation
Since `Option.verify()` can handle normalization of option names, this allows options to define defaults which rely on that normalization. For example, it allows a world to exclude certain locations by default. This also makes it easier to catch errors if a world author accidentally sets an invalid default.
Co-authored-by: Doug Hoskisson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change makes sense, I tested it by excluding the "Tutorial (Outside)" group by default in The Witness, which correctly evaluated to the corresponding locations.
else: | ||
setattr(ret, option_key, option.from_any(option.default)) # call the from_any here to support default "random" | ||
player_option.verify(AutoWorldRegister.world_types[ret.game], ret.name, plando_options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know try -> except -> else
existed. Reading up on it, it seems kind of not necessary in this case, as the except
block re-raises the Exception anyway, which exits the function, meaning there is no scenario in which "you need to prevent something running after the except
". But maybe I'm missing nuance, and hey, it's not wrong or anything, it just took me by surprise. Also it mirrors the old code so I guess it's fine
Option
s.Option
s.
* Verify the default values of `Option`s. Since `Option.verify()` can handle normalization of option names, this allows options to define defaults which rely on that normalization. For example, it allows a world to exclude certain locations by default. This also makes it easier to catch errors if a world author accidentally sets an invalid default. * Update Generate.py Co-authored-by: Doug Hoskisson <[email protected]> --------- Co-authored-by: Doug Hoskisson <[email protected]> Co-authored-by: NewSoupVi <[email protected]>
* Verify the default values of `Option`s. Since `Option.verify()` can handle normalization of option names, this allows options to define defaults which rely on that normalization. For example, it allows a world to exclude certain locations by default. This also makes it easier to catch errors if a world author accidentally sets an invalid default. * Update Generate.py Co-authored-by: Doug Hoskisson <[email protected]> --------- Co-authored-by: Doug Hoskisson <[email protected]> Co-authored-by: NewSoupVi <[email protected]>
What is this fixing or adding?
Since
Option.verify()
can handle normalization of option names, this allows options to define defaults which rely on that normalization. For example, it allows a world to exclude certain locations by default.This also makes it easier to catch errors if a world author accidentally sets an invalid default.
How was this tested?
I set up a world to exclude a name group by default, ran a generation with default options, and verified that all locations in that group were excluded.