-
Notifications
You must be signed in to change notification settings - Fork 701
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
Core: move PlandoConnections and PlandoTexts to the options system #2904
Conversation
the only world to use it is Tunic anyways
I'm the one doing the ER and connection plando stuff for Tunic, so I'm approving this in Silent's stead. Well, approving the Tunic change anyway. I'll try to remember to actually review this tonight -- it looked fine already just skimming the code, but I want to do test gens and such for an actual review. |
This comment was marked as resolved.
This comment was marked as resolved.
fix some issues
Updated for KDL3. |
Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
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.
code looks fine other than some style gripes. i'm not really sure some of these typing hints are useful since they have Any
in them and it might be better to force/assert them as the correct type at some point instead? and then i think two implementation detail questions i had.
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.
resubmitting review from earlier because my comment lines got fucked up for some reason
def can_connect(cls, entrance: str, exit: str) -> bool: | ||
"""Checks that a given entrance can connect to a given exit. | ||
By default, this will always return true unless overridden.""" | ||
return True |
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.
are we sure this should be the default behavior? it seems like enough of the worlds that use this would be fine with it (and my world is too) but it almost feels backwards.
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.
It primarily does two things.
As you've said, it's sufficient for worlds that don't have wild constraints on possible connections. It also simplifies backward compatibility with the currently implemented games, as they already have to check for whether or not the plando is a valid connection, so we can skip the option-based check (the exception being Minecraft, as it's can_connect was simple enough to implement on the option itself).
Options.py
Outdated
percentage: 100 | ||
Direction must be one of 'entrance', 'exit', or 'both', and defaults to 'both' if omitted. | ||
Percentage is an integer from 1 to 100, and defaults to 100 when omitted.""" | ||
class Direction: |
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.
if this is going to be a scoped class like this it should probably be in the PlandoConnection one instead of here so that the direction can be correctly typed?
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 agree with this.
But also, maybe an Enum
?
(The downside to making it an Enum
is the long definition... PlandoConnection.Direction.both
compared to "both"
)
So another alternative is no class, just a type alias:
PlandoConnectionDirection = typing.Literal["entrance", "exit", "both"]
class PlandoConnection(typing.NamedTuple):
entrance: str
exit: str
direction: PlandoConnectionDirection
percentage: int = 100
(I think a type alias has to be gloabal scope.)
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.
Once 3.8 is dropped, StrEnum would probably be a good option. Not sure what the best option is for right now.
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 don't see what value StrEnum
would have over Enum
for this.
The values in a normal Enum
can be str
.
StrEnum
is for when you want to pass it to a function that only takes str
, or use str
methods like lower
, but I don't see you doing any of that here.
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.
It almost seems better to make the values:
class Direction(Enum):
ENTRANCE = "=>"
EXIT = "<="
BOTH = "<=>"
so that you could use those values in get_option_name
(and simplify the code there)
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.
the issue with that is that the existing implementations specifically compare the string when resolving the connections, so it'd need to be an alias of some sort.
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.
Ok, I didn't realize this was connecting with past implementations.
The Messenger: fix portal plando
Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
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.
Scrolled over it, looks fine. Didn't test anything.
|
is there a reason they don't just inherit from OptionList? it has the necessary overrides to do exactly as requested here |
This code would also fail on an OptionList, as it does not override explicit "insert" and "remove", nor does it inherit it from Option or VerifyKeys. |
…rchipelagoMW#2904) Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> Co-authored-by: Scipio Wright <scipiowright@gmail.com> Co-authored-by: beauxq <beauxq@yahoo.com> Co-authored-by: alwaysintreble <mmmcheese158@gmail.com>
…rchipelagoMW#2904) Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> Co-authored-by: Scipio Wright <scipiowright@gmail.com> Co-authored-by: beauxq <beauxq@yahoo.com> Co-authored-by: alwaysintreble <mmmcheese158@gmail.com>
…rchipelagoMW#2904) Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> Co-authored-by: Scipio Wright <scipiowright@gmail.com> Co-authored-by: beauxq <beauxq@yahoo.com> Co-authored-by: alwaysintreble <mmmcheese158@gmail.com>
…rchipelagoMW#2904) Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com> Co-authored-by: Scipio Wright <scipiowright@gmail.com> Co-authored-by: beauxq <beauxq@yahoo.com> Co-authored-by: alwaysintreble <mmmcheese158@gmail.com>
What is this fixing or adding?
Moves plando connections and texts to the options system. In order to use plando connections and texts, worlds will need to define the option in their options dataclass/definitions, and supported games will have plando connections and texts appear within the template yaml. Additionally, rolled plando connections/texts will appear in the spoiler log.
This includes changes to LttP, OoT, Minecraft, and TUNIC as they use plando connections currently (or plan to in the near future).
How was this tested?
Manually, by generating games using plando connections and confirming that the resulting connection was proper.
Texts was tested by generating a game using the mercenary mode trigger block, and confirming that the text was correctly placed.
No automated testing has been added.
If this makes graphical changes, please attach screenshots.
Excerpt from LttP template:
Excerpt from spoiler log: