Skip to content
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: remove module level AutoWorld import from BaseClasses #2790

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
import Options
import Utils

if typing.TYPE_CHECKING:
from worlds import AutoWorld


class Group(TypedDict, total=False):
name: str
game: str
world: auto_world
world: "AutoWorld.World"
players: Set[int]
item_pool: Set[str]
replacement_items: Dict[int, Optional[str]]
Expand Down Expand Up @@ -55,7 +58,7 @@ class MultiWorld():
plando_texts: List[Dict[str, str]]
plando_items: List[List[Dict[str, Any]]]
plando_connections: List
worlds: Dict[int, auto_world]
worlds: Dict[int, "AutoWorld.World"]
groups: Dict[int, Group]
regions: RegionManager
itempool: List[Item]
Expand Down Expand Up @@ -219,6 +222,8 @@ def get_all_ids(self) -> Tuple[int, ...]:
def add_group(self, name: str, game: str, players: Set[int] = frozenset()) -> Tuple[int, Group]:
"""Create a group with name and return the assigned player ID and group.
If a group of this name already exists, the set of players is extended instead of creating a new one."""
from worlds import AutoWorld

for group_id, group in self.groups.items():
if group["name"] == name:
group["players"] |= players
Expand Down Expand Up @@ -253,6 +258,8 @@ def set_seed(self, seed: Optional[int] = None, secure: bool = False, name: Optio

def set_options(self, args: Namespace) -> None:
# TODO - remove this section once all worlds use options dataclasses
from worlds import AutoWorld

all_keys: Set[str] = {key for player in self.player_ids for key in
AutoWorld.AutoWorldRegister.world_types[self.game[player]].options_dataclass.type_hints}
for option_key in all_keys:
Expand All @@ -270,6 +277,8 @@ def set_options(self, args: Namespace) -> None:
for option_key in options_dataclass.type_hints})

def set_item_links(self):
from worlds import AutoWorld

item_links = {}
replacement_prio = [False, True, None]
for player in self.player_ids:
Expand Down Expand Up @@ -1326,6 +1335,8 @@ def get_path(state: CollectionState, region: Region) -> List[Union[Tuple[str, st
get_path(state, multiworld.get_region('Inverted Big Bomb Shop', player))

def to_file(self, filename: str) -> None:
from worlds import AutoWorld

def write_option(option_key: str, option_obj: Options.AssembleOptions) -> None:
res = getattr(self.multiworld.worlds[player].options, option_key)
display_name = getattr(option_obj, "display_name", option_key)
Expand Down Expand Up @@ -1449,8 +1460,3 @@ def get_seed(seed: Optional[int] = None) -> int:
random.seed(None)
return random.randint(0, pow(10, seeddigits) - 1)
return seed


from worlds import AutoWorld

auto_world = AutoWorld.World
Loading