Core: Make region.add_exits return the created Entrances (#3885)

* Core: Make region.add_exits return the created Entrances

* Update BaseClasses.py

* Update BaseClasses.py

Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>

---------

Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
This commit is contained in:
NewSoupVi 2024-11-29 01:41:13 +01:00 committed by GitHub
parent ce78c75999
commit 62e4285924
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 5 deletions

View File

@ -1110,7 +1110,7 @@ class Region:
return exit_ return exit_
def add_exits(self, exits: Union[Iterable[str], Dict[str, Optional[str]]], def add_exits(self, exits: Union[Iterable[str], Dict[str, Optional[str]]],
rules: Dict[str, Callable[[CollectionState], bool]] = None) -> None: rules: Dict[str, Callable[[CollectionState], bool]] = None) -> List[Entrance]:
""" """
Connects current region to regions in exit dictionary. Passed region names must exist first. Connects current region to regions in exit dictionary. Passed region names must exist first.
@ -1120,10 +1120,14 @@ class Region:
""" """
if not isinstance(exits, Dict): if not isinstance(exits, Dict):
exits = dict.fromkeys(exits) exits = dict.fromkeys(exits)
for connecting_region, name in exits.items(): return [
self.connect(self.multiworld.get_region(connecting_region, self.player), self.connect(
self.multiworld.get_region(connecting_region, self.player),
name, name,
rules[connecting_region] if rules and connecting_region in rules else None) rules[connecting_region] if rules and connecting_region in rules else None,
)
for connecting_region, name in exits.items()
]
def __repr__(self): def __repr__(self):
return self.multiworld.get_name_string_for_object(self) if self.multiworld else f'{self.name} (Player {self.player})' return self.multiworld.get_name_string_for_object(self) if self.multiworld else f'{self.name} (Player {self.player})'