diff --git a/worlds/grinch/Options.py b/worlds/grinch/Options.py index 845b9b79..aa9b5cd5 100644 --- a/worlds/grinch/Options.py +++ b/worlds/grinch/Options.py @@ -57,6 +57,9 @@ class UnlimitedRottenEggs(Toggle): """Determine whether or not you run out of rotten eggs when you utilize your gadgets.""" display_name = "Unlimited Rotten Eggs" +class RingLinkOption(Toggle): + """Whenever this is toggled, your ammo is linked with other ringlink-compatible games that also have this enabled""" + @dataclass class GrinchOptions(PerGameCommonOptions):#DeathLinkMixin progressive_vacuum: ProgressiveVacuum diff --git a/worlds/grinch/Regions.py b/worlds/grinch/Regions.py index 341f2e7d..dfcc9084 100644 --- a/worlds/grinch/Regions.py +++ b/worlds/grinch/Regions.py @@ -6,8 +6,7 @@ from .Options import GrinchOptions from BaseClasses import Region from .Rules import access_rules_dict, interpret_rule -import logging -logger = logging.getLogger() +from ..generic.Rules import add_rule if TYPE_CHECKING: @@ -54,16 +53,17 @@ def create_regions(world: "GrinchWorld"): world.multiworld.regions.append(Region(supadow, world.player, world.multiworld)) def grinchconnect(world: "GrinchWorld", current_region_name: str, connected_region_name: str): - logger.info("Current Region Name: "+ current_region_name) - logger.info("Connected Region Name: "+ connected_region_name) current_region = world.get_region(current_region_name) connected_region = world.get_region(connected_region_name) required_items: list[list[str]] = access_rules_dict[connected_region.name] - rule = interpret_rule(required_items, world.player) - #Goes from current to connected - current_region.connect(connected_region, rule = rule) - #Goes from connected to current - connected_region.connect(current_region, rule = rule) + rule_list = interpret_rule(required_items, world.player) + # Goes from current to connected + current_region.connect(connected_region) + # Goes from connected to current + connected_region.connect(current_region) + for access_rule in rule_list: + add_rule(current_region.entrances[current_region.entrances.index(next(loc_entrance for loc_entrance in current_region.entrances if loc_entrance.name.startswith(connected_region_name)))], access_rule) + add_rule(connected_region.entrances[connected_region.entrances.index(next(loc_entrance for loc_entrance in connected_region.entrances if loc_entrance.name.startswith(current_region_name)))], access_rule) def connect_regions(world: "GrinchWorld"): grinchconnect(world, "Mount Crumpit", "Whoville") @@ -71,9 +71,9 @@ def connect_regions(world: "GrinchWorld"): grinchconnect(world, "Mount Crumpit", "Who Dump") grinchconnect(world, "Mount Crumpit", "Who Lake") grinchconnect(world, "Mount Crumpit", "Sleigh Room") - # grinchconnect(world, "Mount Crumpit", "Spin N' Win Supadow") - # grinchconnect(world, "Mount Crumpit", "Dankamania Supadow") - # grinchconnect(world, "Mount Crumpit", "The Copter Race Contest Supadow") + grinchconnect(world, "Mount Crumpit", "Spin N' Win Supadow") + grinchconnect(world, "Mount Crumpit", "Dankamania Supadow") + grinchconnect(world, "Mount Crumpit", "The Copter Race Contest Supadow") grinchconnect(world, "Whoville", "Post Office") grinchconnect(world, "Whoville", "City Hall") grinchconnect(world, "Whoville", "Countdown to X-Mas Clock Tower") diff --git a/worlds/grinch/Rules.py b/worlds/grinch/Rules.py index 0bc0c1d3..95e4e61b 100644 --- a/worlds/grinch/Rules.py +++ b/worlds/grinch/Rules.py @@ -1,15 +1,16 @@ +from typing import Callable + +from BaseClasses import CollectionState from worlds.AutoWorld import World -# from .Options import GrinchOptions from worlds.generic.Rules import add_rule -import logging -logger = logging.getLogger() def set_rules(world: World): all_locations = world.get_locations() for location in all_locations: loc_rules = rules_dict[location.name] - rule = interpret_rule(loc_rules, world.player) - add_rule(location, rule) + rule_list = interpret_rule(loc_rules, world.player) + for access_rule in rule_list: + add_rule(location, access_rule) rules_dict: dict[str,list[list[str]]] = { @@ -445,17 +446,26 @@ access_rules_dict: dict[str,list[list[str]]] = { ], "Sleigh Room": [ ["Exhaust Pipes", "GPS", "Tires", "Skis", "Twin-End Tuba"] - ] + ], + "Spin N' Win Supadow": [ + ["Spin N' Win Door Unlock"], + # ["Progressive Supadow Door Unlock"] + ], + "Dankamania Supadow": [ + ["Dankamania Door Unlock"], + # ["Progressive Supadow Door Unlock: 2"] + ], + "The Copter Race Contest Supadow": [ + ["The Copter Race Contest Door Unlock"], + # ["Progressive Supadow Door Unlock: 3"] + ], } - def interpret_rule(rule_set: list[list[str]], player: int): - old_rule = lambda state: True if len(rule_set) < 1: - return old_rule - else: - old_rule = lambda state: False + return True + + access_list: list[Callable[[CollectionState], bool]] = [] for item_set in rule_set: - logger.info("Rules to access: " + ";".join(item_set)) - old_rule = lambda state, items=item_set: state.has_all(items, player) or old_rule - return old_rule \ No newline at end of file + access_list.append(lambda state: state.has_all(item_set, player)) + return access_list \ No newline at end of file diff --git a/worlds/grinch/docs/Credits.md b/worlds/grinch/docs/Credits.md index fe65d817..1dc5f1a2 100644 --- a/worlds/grinch/docs/Credits.md +++ b/worlds/grinch/docs/Credits.md @@ -1,2 +1,3 @@ -- Credit to Raven-187 on gamehacking.org for providing the addresses for various cheat codes. Without them, would of made RAM searching much more tedious. -- Shoutouts to SomeJakeGuy for basically teaching me how to code, in general. \ No newline at end of file +- Credit to Raven-187 & Hacc on gamehacking.org for providing the addresses for various cheat codes. Without them, would of made RAM searching much more tedious. +- Shoutouts to SomeJakeGuy for basically teaching me how to code, in general. +- Shoutouts to BootsinSoots for helping with the implementation of the logic rules code itself \ No newline at end of file