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."""
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

View File

@@ -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")

View File

@@ -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
access_list.append(lambda state: state.has_all(item_set, player))
return access_list

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.
- Shoutouts to SomeJakeGuy for basically teaching me how to code, in general.
- 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