-
Notifications
You must be signed in to change notification settings - Fork 722
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: Region connection helpers #1923
Core: Region connection helpers #1923
Conversation
|
Probably not but this was the first thing I thought of. I'm open to a better way to handle this.
Could update create exit so it accepts a class like add_locations or alternatively it could just be subclassed. I feel like if you're subclassing Entrance, you're likely subclassing Region already. |
I'm not a fan of marking direct Entrance creation as "deprecated". Obviously, want to encourage folks to use the AP helper methods, but if folks know what they're doing and have good reason to, I don't want to nag them with a deprecation warning, implying it's going to be removed. And that's better than making a monster of a helper method that can handle every possible use case. |
BaseClasses.py
Outdated
"""Adds locations to the Region object, where location_type is your Location class and locations is a dict of | ||
location names to address.""" | ||
def add_locations(self, locations: Dict[str, Optional[int]], | ||
location_type: Optional[typing.Type[Location]] = None) -> None: |
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.
There's a bit of an asymmetry between add_locations
, which takes the location_type
as an argument, and create_exit
, which reads the entrance_type
from an attribute.
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 think the asymmetry is ok. There's use cases where we might want multiple Location classes in a Region (Messenger already does this), though very unlikely we have the same for Entrances.
4562c57
to
f9d4387
Compare
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.
Think this is fine now. Further improvements can be done on top of this without breaking backwards compat.
Adding a warning / deprecating the old way of things should be opened as separate PR and merged once we know for sure this solution is flexible enough to update all worlds.
* Region.create_exit and Region.connect helpers * reduce code duplication and better naming in Region.connect * thank you tests * reorder class definition * define entrance_type on Region * document helpers * drop __class_getitem__ for now * review changes
* Region.create_exit and Region.connect helpers * reduce code duplication and better naming in Region.connect * thank you tests * reorder class definition * define entrance_type on Region * document helpers * drop __class_getitem__ for now * review changes
Please format your title with what portion of the project this pull request is
targeting and what it's changing.
ex. "MyGame4: implement new game" or "Docs: add new guide for customizing MyGame3"
What is this fixing or adding?
Region.connect
andRegion.create_exit
. latter returns an entrance that can be used for other things (?) and former allows easy connection between two regions without needing the full structure ofadd_exits
. Also added deprecation warning to creating Entrance elsewhere, since there's a ton of duplicated code from people doing so. Made it a separate commit so it can be easily dropped if desired.How was this tested?
unit tests and checking that the logs print the warning correctly
If this makes graphical changes, please attach screenshots.