From 7e70b16656b7382528fa7c679c4ff1aad3eec209 Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Sun, 24 Dec 2023 13:34:25 -0800 Subject: [PATCH] Clique: use options.name instead of multiworld.name --- worlds/clique/Items.py | 9 +++++---- worlds/clique/Locations.py | 8 +++++--- worlds/clique/Rules.py | 7 ++++--- worlds/clique/__init__.py | 12 ++++++------ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/worlds/clique/Items.py b/worlds/clique/Items.py index 5474f58b82..12ce2e28d5 100644 --- a/worlds/clique/Items.py +++ b/worlds/clique/Items.py @@ -1,6 +1,7 @@ from typing import Callable, Dict, NamedTuple, Optional -from BaseClasses import Item, ItemClassification, MultiWorld +from BaseClasses import Item, ItemClassification +from Options import PerGameCommonOptions class CliqueItem(Item): @@ -10,7 +11,7 @@ class CliqueItem(Item): class CliqueItemData(NamedTuple): code: Optional[int] = None type: ItemClassification = ItemClassification.filler - can_create: Callable[[MultiWorld, int], bool] = lambda multiworld, player: True + can_create: Callable[[PerGameCommonOptions], bool] = lambda options: True item_data_table: Dict[str, CliqueItemData] = { @@ -21,11 +22,11 @@ item_data_table: Dict[str, CliqueItemData] = { "Button Activation": CliqueItemData( code=69696968, type=ItemClassification.progression, - can_create=lambda multiworld, player: bool(getattr(multiworld, "hard_mode")[player]), + can_create=lambda options: bool(getattr(options, "hard_mode")), ), "A Cool Filler Item (No Satisfaction Guaranteed)": CliqueItemData( code=69696967, - can_create=lambda multiworld, player: False # Only created from `get_filler_item_name`. + can_create=lambda options: False # Only created from `get_filler_item_name`. ), "The Urge to Push": CliqueItemData( type=ItemClassification.progression, diff --git a/worlds/clique/Locations.py b/worlds/clique/Locations.py index 144becae53..4f7872843e 100644 --- a/worlds/clique/Locations.py +++ b/worlds/clique/Locations.py @@ -1,6 +1,8 @@ from typing import Callable, Dict, NamedTuple, Optional -from BaseClasses import Location, MultiWorld +from BaseClasses import Location +from Options import PerGameCommonOptions + class CliqueLocation(Location): @@ -10,7 +12,7 @@ class CliqueLocation(Location): class CliqueLocationData(NamedTuple): region: str address: Optional[int] = None - can_create: Callable[[MultiWorld, int], bool] = lambda multiworld, player: True + can_create: Callable[[PerGameCommonOptions], bool] = lambda options: True locked_item: Optional[str] = None @@ -22,7 +24,7 @@ location_data_table: Dict[str, CliqueLocationData] = { "The Item on the Desk": CliqueLocationData( region="The Button Realm", address=69696968, - can_create=lambda multiworld, player: bool(getattr(multiworld, "hard_mode")[player]), + can_create=lambda options: bool(getattr(options, "hard_mode")), ), "In the Player's Mind": CliqueLocationData( region="The Button Realm", diff --git a/worlds/clique/Rules.py b/worlds/clique/Rules.py index 5ae1d2c68e..bcb276217d 100644 --- a/worlds/clique/Rules.py +++ b/worlds/clique/Rules.py @@ -1,10 +1,11 @@ from typing import Callable -from BaseClasses import CollectionState, MultiWorld +from BaseClasses import CollectionState +from Options import PerGameCommonOptions -def get_button_rule(multiworld: MultiWorld, player: int) -> Callable[[CollectionState], bool]: - if getattr(multiworld, "hard_mode")[player]: +def get_button_rule(options: PerGameCommonOptions, player: int) -> Callable[[CollectionState], bool]: + if getattr(options, "hard_mode"): return lambda state: state.has("Button Activation", player) return lambda state: True diff --git a/worlds/clique/__init__.py b/worlds/clique/__init__.py index 5838389047..0e0eb38113 100644 --- a/worlds/clique/__init__.py +++ b/worlds/clique/__init__.py @@ -39,7 +39,7 @@ class CliqueWorld(World): def create_items(self) -> None: item_pool: List[CliqueItem] = [] for name, item in item_data_table.items(): - if item.code and item.can_create(self.multiworld, self.player): + if item.code and item.can_create(self.options): item_pool.append(self.create_item(name)) self.multiworld.itempool += item_pool @@ -55,27 +55,27 @@ class CliqueWorld(World): region = self.multiworld.get_region(region_name, self.player) region.add_locations({ location_name: location_data.address for location_name, location_data in location_data_table.items() - if location_data.region == region_name and location_data.can_create(self.multiworld, self.player) + if location_data.region == region_name and location_data.can_create(self.options) }, CliqueLocation) region.add_exits(region_data_table[region_name].connecting_regions) # Place locked locations. for location_name, location_data in locked_locations.items(): # Ignore locations we never created. - if not location_data.can_create(self.multiworld, self.player): + if not location_data.can_create(self.options): continue locked_item = self.create_item(location_data_table[location_name].locked_item) self.multiworld.get_location(location_name, self.player).place_locked_item(locked_item) # Set priority location for the Big Red Button! - self.multiworld.priority_locations[self.player].value.add("The Big Red Button") + self.options.priority_locations.value.add("The Big Red Button") def get_filler_item_name(self) -> str: return "A Cool Filler Item (No Satisfaction Guaranteed)" def set_rules(self) -> None: - button_rule = get_button_rule(self.multiworld, self.player) + button_rule = get_button_rule(self.options, self.player) self.multiworld.get_location("The Big Red Button", self.player).access_rule = button_rule self.multiworld.get_location("In the Player's Mind", self.player).access_rule = button_rule @@ -88,5 +88,5 @@ class CliqueWorld(World): def fill_slot_data(self): return { - "color": getattr(self.multiworld, "color")[self.player].current_key + "color": getattr(self.options, "color").current_key }