diff --git a/worlds/grinch/Regions.py b/worlds/grinch/Regions.py index abb334bd..2b325b6a 100644 --- a/worlds/grinch/Regions.py +++ b/worlds/grinch/Regions.py @@ -50,6 +50,7 @@ def create_regions(world: "GrinchWorld"): #Each area in supadow, create a region for the given player world.multiworld.regions.append(Region(supadow, world.player, world.multiworld)) +# TODO Optimize this function def grinchconnect(world: "GrinchWorld", current_region_name: str, connected_region_name: str): current_region = world.get_region(current_region_name) connected_region = world.get_region(connected_region_name) @@ -63,11 +64,17 @@ def grinchconnect(world: "GrinchWorld", current_region_name: str, connected_regi for region_entrance in current_region.entrances: if region_entrance.connected_region.name == current_region_name and \ region_entrance.parent_region.name == connected_region_name: - add_rule(region_entrance, access_rule) + if rule_list.index(access_rule) == 0: + add_rule(region_entrance, access_rule) + else: + add_rule(region_entrance, access_rule, combine="or") for region_entrance in connected_region.entrances: if region_entrance.connected_region.name == connected_region_name and \ region_entrance.parent_region.name == current_region_name: - add_rule(region_entrance, access_rule) + if rule_list.index(access_rule) == 0: + add_rule(region_entrance, access_rule) + else: + add_rule(region_entrance, access_rule, combine="or") #What regions are connected to each other def connect_regions(world: "GrinchWorld"): diff --git a/worlds/grinch/Rules.py b/worlds/grinch/Rules.py index 2fa58655..5c5b773a 100644 --- a/worlds/grinch/Rules.py +++ b/worlds/grinch/Rules.py @@ -1,17 +1,21 @@ from typing import Callable +import Utils from BaseClasses import CollectionState from worlds.AutoWorld import World from worlds.generic.Rules import add_rule #Adds all rules from access_rules_dict to locations -def set_rules(world: World): +def set_location_rules(world: World): all_locations = world.get_locations() for location in all_locations: loc_rules = rules_dict[location.name] rule_list = interpret_rule(loc_rules, world.player) for access_rule in rule_list: - add_rule(location, access_rule) + if rule_list.index(access_rule) == 0: + add_rule(location, access_rule) + else: + add_rule(location, access_rule, "or") def interpret_rule(rule_set: list[list[str]], player: int): # If a region/location does not have any items required, make the section(s) return no logic. diff --git a/worlds/grinch/__init__.py b/worlds/grinch/__init__.py index 21e9e1d4..fb914dfe 100644 --- a/worlds/grinch/__init__.py +++ b/worlds/grinch/__init__.py @@ -2,7 +2,7 @@ from BaseClasses import Region, Item, ItemClassification from .Locations import grinch_locations_to_id, grinch_locations, GrinchLocation from .Items import grinch_items_to_id, GrinchItem, ALL_ITEMS_TABLE, MISC_ITEMS_TABLE from .Regions import connect_regions -from .Rules import set_rules +from .Rules import set_location_rules from .Client import * from typing import ClassVar @@ -64,7 +64,7 @@ class GrinchWorld(World): def set_rules(self): self.multiworld.completion_condition[self.player] = lambda state: state.has("Goal", self.player) - set_rules(self) + set_location_rules(self) def get_other_filler_item(self, other_filler: list[str]) -> str: return self.random.choices(other_filler)[0]