Skip to content

Commit

Permalink
Core: Make region.add_exits return the created Entrances (#3885)
Browse files Browse the repository at this point in the history
* Core: Make region.add_exits return the created Entrances

* Update BaseClasses.py

* Update BaseClasses.py

Co-authored-by: Doug Hoskisson <[email protected]>

---------

Co-authored-by: Doug Hoskisson <[email protected]>
  • Loading branch information
NewSoupVi and beauxq authored Nov 29, 2024
1 parent ce78c75 commit 62e4285
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ def create_exit(self, name: str) -> Entrance:
return exit_

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.
Expand All @@ -1120,10 +1120,14 @@ def add_exits(self, exits: Union[Iterable[str], Dict[str, Optional[str]]],
"""
if not isinstance(exits, Dict):
exits = dict.fromkeys(exits)
for connecting_region, name in exits.items():
self.connect(self.multiworld.get_region(connecting_region, self.player),
name,
rules[connecting_region] if rules and connecting_region in rules else None)
return [
self.connect(
self.multiworld.get_region(connecting_region, self.player),
name,
rules[connecting_region] if rules and connecting_region in rules else None,
)
for connecting_region, name in exits.items()
]

def __repr__(self):
return self.multiworld.get_name_string_for_object(self) if self.multiworld else f'{self.name} (Player {self.player})'
Expand Down

0 comments on commit 62e4285

Please sign in to comment.