mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Fix location & region logic not considering OR logic via multiple lists of items
This commit is contained in:
@@ -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"):
|
||||
|
@@ -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.
|
||||
|
@@ -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]
|
||||
|
Reference in New Issue
Block a user