diff --git a/worlds/witness/__init__.py b/worlds/witness/__init__.py index c38898b3..e985dde3 100644 --- a/worlds/witness/__init__.py +++ b/worlds/witness/__init__.py @@ -44,10 +44,6 @@ class WitnessWorld(World): """ game = "The Witness" topology_present = False - - StaticWitnessLogic() - StaticWitnessLocations() - StaticWitnessItems() web = WitnessWebWorld() options_dataclass = TheWitnessOptions diff --git a/worlds/witness/items.py b/worlds/witness/items.py index 41bc3c1b..6802fd2a 100644 --- a/worlds/witness/items.py +++ b/worlds/witness/items.py @@ -176,9 +176,14 @@ class WitnessPlayerItems: # Read trap configuration data. trap_weight = self._world.options.trap_percentage / 100 - filler_weight = 1 - trap_weight + trap_items = self._world.options.trap_weights.value + + if not sum(trap_items.values()): + trap_weight = 0 # Add filler items to the list. + filler_weight = 1 - trap_weight + filler_items: Dict[str, float] filler_items = {name: data.definition.weight if isinstance(data.definition, WeightedItemDefinition) else 1 for (name, data) in self.item_data.items() if data.definition.category is ItemCategory.FILLER} @@ -187,8 +192,6 @@ class WitnessPlayerItems: # Add trap items. if trap_weight > 0: - trap_items = {name: data.definition.weight if isinstance(data.definition, WeightedItemDefinition) else 1 - for (name, data) in self.item_data.items() if data.definition.category is ItemCategory.TRAP} filler_items.update({name: base_weight * trap_weight / sum(trap_items.values()) for name, base_weight in trap_items.items() if base_weight > 0}) @@ -267,3 +270,6 @@ class WitnessPlayerItems: output[item.ap_code] = [StaticWitnessItems.item_data[child_item].ap_code for child_item in item.definition.child_item_names] return output + + +StaticWitnessItems() diff --git a/worlds/witness/locations.py b/worlds/witness/locations.py index d38cf902..cd6d71f4 100644 --- a/worlds/witness/locations.py +++ b/worlds/witness/locations.py @@ -569,3 +569,6 @@ class WitnessPlayerLocations: entity_hex = StaticWitnessLogic.ENTITIES_BY_NAME[entity_name]["entity_hex"] self.CHECK_LOCATION_TABLE[entity_hex] = entity_name self.CHECK_PANELHEX_TO_ID[entity_hex] = StaticWitnessLocations.get_id(entity_hex) + + +StaticWitnessLocations() diff --git a/worlds/witness/options.py b/worlds/witness/options.py index 68a4ac7f..18aa76d9 100644 --- a/worlds/witness/options.py +++ b/worlds/witness/options.py @@ -1,5 +1,10 @@ from dataclasses import dataclass -from Options import Toggle, DefaultOnToggle, Range, Choice, PerGameCommonOptions + +from schema import Schema, And, Optional + +from Options import Toggle, DefaultOnToggle, Range, Choice, PerGameCommonOptions, OptionDict + +from worlds.witness.static_logic import WeightedItemDefinition, ItemCategory, StaticWitnessLogic class DisableNonRandomizedPuzzles(Toggle): @@ -172,6 +177,24 @@ class TrapPercentage(Range): default = 20 +class TrapWeights(OptionDict): + """Specify the weights determining how many copies of each trap item will be in your itempool. + If you don't want a specific type of trap, you can set the weight for it to 0 (Do not delete the entry outright!). + If you set all trap weights to 0, you will get no traps, bypassing the "Trap Percentage" option.""" + + display_name = "Trap Weights" + schema = Schema({ + trap_name: And(int, lambda n: n >= 0) + for trap_name, item_definition in StaticWitnessLogic.all_items.items() + if isinstance(item_definition, WeightedItemDefinition) and item_definition.category is ItemCategory.TRAP + }) + default = { + trap_name: item_definition.weight + for trap_name, item_definition in StaticWitnessLogic.all_items.items() + if isinstance(item_definition, WeightedItemDefinition) and item_definition.category is ItemCategory.TRAP + } + + class PuzzleSkipAmount(Range): """Adds this number of Puzzle Skips into the pool, if there is room. Puzzle Skips let you skip one panel. Works on most panels in the game - The only big exception is The Challenge.""" @@ -237,6 +260,7 @@ class TheWitnessOptions(PerGameCommonOptions): early_caves: EarlyCaves elevators_come_to_you: ElevatorsComeToYou trap_percentage: TrapPercentage + trap_weights: TrapWeights puzzle_skip_amount: PuzzleSkipAmount hint_amount: HintAmount area_hint_percentage: AreaHintPercentage diff --git a/worlds/witness/static_logic.py b/worlds/witness/static_logic.py index 5a3e8b1b..3efab491 100644 --- a/worlds/witness/static_logic.py +++ b/worlds/witness/static_logic.py @@ -295,3 +295,6 @@ class StaticWitnessLogic: self.EP_TO_OBELISK_SIDE.update(self.sigma_normal.EP_TO_OBELISK_SIDE) self.ENTITY_ID_TO_NAME.update(self.sigma_normal.ENTITY_ID_TO_NAME) + + +StaticWitnessLogic()