Regions now connecting as god intended

This commit is contained in:
MarioSpore
2025-08-03 13:39:32 -04:00
parent b622953cd0
commit cf921a8f54
4 changed files with 42 additions and 28 deletions

View File

@@ -57,6 +57,9 @@ class UnlimitedRottenEggs(Toggle):
"""Determine whether or not you run out of rotten eggs when you utilize your gadgets.""" """Determine whether or not you run out of rotten eggs when you utilize your gadgets."""
display_name = "Unlimited Rotten Eggs" 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 @dataclass
class GrinchOptions(PerGameCommonOptions):#DeathLinkMixin class GrinchOptions(PerGameCommonOptions):#DeathLinkMixin
progressive_vacuum: ProgressiveVacuum progressive_vacuum: ProgressiveVacuum

View File

@@ -6,8 +6,7 @@ from .Options import GrinchOptions
from BaseClasses import Region from BaseClasses import Region
from .Rules import access_rules_dict, interpret_rule from .Rules import access_rules_dict, interpret_rule
import logging from ..generic.Rules import add_rule
logger = logging.getLogger()
if TYPE_CHECKING: if TYPE_CHECKING:
@@ -54,16 +53,17 @@ def create_regions(world: "GrinchWorld"):
world.multiworld.regions.append(Region(supadow, world.player, world.multiworld)) world.multiworld.regions.append(Region(supadow, world.player, world.multiworld))
def grinchconnect(world: "GrinchWorld", current_region_name: str, connected_region_name: str): 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) current_region = world.get_region(current_region_name)
connected_region = world.get_region(connected_region_name) connected_region = world.get_region(connected_region_name)
required_items: list[list[str]] = access_rules_dict[connected_region.name] required_items: list[list[str]] = access_rules_dict[connected_region.name]
rule = interpret_rule(required_items, world.player) rule_list = interpret_rule(required_items, world.player)
#Goes from current to connected # Goes from current to connected
current_region.connect(connected_region, rule = rule) current_region.connect(connected_region)
#Goes from connected to current # Goes from connected to current
connected_region.connect(current_region, rule = rule) 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"): def connect_regions(world: "GrinchWorld"):
grinchconnect(world, "Mount Crumpit", "Whoville") 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 Dump")
grinchconnect(world, "Mount Crumpit", "Who Lake") grinchconnect(world, "Mount Crumpit", "Who Lake")
grinchconnect(world, "Mount Crumpit", "Sleigh Room") grinchconnect(world, "Mount Crumpit", "Sleigh Room")
# grinchconnect(world, "Mount Crumpit", "Spin N' Win Supadow") grinchconnect(world, "Mount Crumpit", "Spin N' Win Supadow")
# grinchconnect(world, "Mount Crumpit", "Dankamania Supadow") grinchconnect(world, "Mount Crumpit", "Dankamania Supadow")
# grinchconnect(world, "Mount Crumpit", "The Copter Race Contest Supadow") grinchconnect(world, "Mount Crumpit", "The Copter Race Contest Supadow")
grinchconnect(world, "Whoville", "Post Office") grinchconnect(world, "Whoville", "Post Office")
grinchconnect(world, "Whoville", "City Hall") grinchconnect(world, "Whoville", "City Hall")
grinchconnect(world, "Whoville", "Countdown to X-Mas Clock Tower") grinchconnect(world, "Whoville", "Countdown to X-Mas Clock Tower")

View File

@@ -1,15 +1,16 @@
from typing import Callable
from BaseClasses import CollectionState
from worlds.AutoWorld import World from worlds.AutoWorld import World
# from .Options import GrinchOptions
from worlds.generic.Rules import add_rule from worlds.generic.Rules import add_rule
import logging
logger = logging.getLogger()
def set_rules(world: World): def set_rules(world: World):
all_locations = world.get_locations() all_locations = world.get_locations()
for location in all_locations: for location in all_locations:
loc_rules = rules_dict[location.name] loc_rules = rules_dict[location.name]
rule = interpret_rule(loc_rules, world.player) rule_list = interpret_rule(loc_rules, world.player)
add_rule(location, rule) for access_rule in rule_list:
add_rule(location, access_rule)
rules_dict: dict[str,list[list[str]]] = { rules_dict: dict[str,list[list[str]]] = {
@@ -445,17 +446,26 @@ access_rules_dict: dict[str,list[list[str]]] = {
], ],
"Sleigh Room": [ "Sleigh Room": [
["Exhaust Pipes", "GPS", "Tires", "Skis", "Twin-End Tuba"] ["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): def interpret_rule(rule_set: list[list[str]], player: int):
old_rule = lambda state: True
if len(rule_set) < 1: if len(rule_set) < 1:
return old_rule return True
else:
old_rule = lambda state: False access_list: list[Callable[[CollectionState], bool]] = []
for item_set in rule_set: for item_set in rule_set:
logger.info("Rules to access: " + ";".join(item_set)) access_list.append(lambda state: state.has_all(item_set, player))
old_rule = lambda state, items=item_set: state.has_all(items, player) or old_rule return access_list
return old_rule

View File

@@ -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. - 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 SomeJakeGuy for basically teaching me how to code, in general.
- Shoutouts to BootsinSoots for helping with the implementation of the logic rules code itself