mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
Core: Add "OptionCounter", use it for generic "StartInventory" and Witness "TrapWeights" (#3756)
* CounterOption * bring back the negative exception for ItemDict * Backwards compatibility * ruff on witness * fix in calls * move the contains * comment * comment * Add option min and max values for CounterOption * Use min 0 for TrapWeights * This is safe now * ruff * This fits on one line again now * OptionCounter * Update Options.py * Couple more typing things * Update Options.py * Make StartInventory work again, also make LocationCounter theoretically work * Docs * more forceful wording * forced line break * Fix unit test (that wasn't breaking?) * Add trapweights to witness option presets to 'prove' that the unit test passes * Make it so you can order stuff * Update macros.html
This commit is contained in:
@@ -7,7 +7,7 @@ from Options import (
|
||||
Choice,
|
||||
DefaultOnToggle,
|
||||
LocationSet,
|
||||
OptionDict,
|
||||
OptionCounter,
|
||||
OptionError,
|
||||
OptionGroup,
|
||||
OptionSet,
|
||||
@@ -414,23 +414,25 @@ class TrapPercentage(Range):
|
||||
default = 20
|
||||
|
||||
|
||||
class TrapWeights(OptionDict):
|
||||
_default_trap_weights = {
|
||||
trap_name: item_definition.weight
|
||||
for trap_name, item_definition in static_witness_logic.ALL_ITEMS.items()
|
||||
if isinstance(item_definition, WeightedItemDefinition) and item_definition.category is ItemCategory.TRAP
|
||||
}
|
||||
|
||||
|
||||
class TrapWeights(OptionCounter):
|
||||
"""
|
||||
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 don't want a specific type of trap, you can set the weight for it to 0.
|
||||
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 static_witness_logic.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 static_witness_logic.ALL_ITEMS.items()
|
||||
if isinstance(item_definition, WeightedItemDefinition) and item_definition.category is ItemCategory.TRAP
|
||||
}
|
||||
valid_keys = _default_trap_weights.keys()
|
||||
|
||||
min = 0
|
||||
|
||||
default = _default_trap_weights
|
||||
|
||||
|
||||
class PuzzleSkipAmount(Range):
|
||||
|
@@ -40,6 +40,8 @@ witness_option_presets: Dict[str, Dict[str, Any]] = {
|
||||
|
||||
"trap_percentage": TrapPercentage.default,
|
||||
"puzzle_skip_amount": PuzzleSkipAmount.default,
|
||||
"trap_weights": TrapWeights.default,
|
||||
|
||||
"hint_amount": HintAmount.default,
|
||||
"area_hint_percentage": AreaHintPercentage.default,
|
||||
"laser_hints": LaserHints.default,
|
||||
@@ -79,6 +81,8 @@ witness_option_presets: Dict[str, Dict[str, Any]] = {
|
||||
|
||||
"trap_percentage": TrapPercentage.default,
|
||||
"puzzle_skip_amount": 15,
|
||||
"trap_weights": TrapWeights.default,
|
||||
|
||||
"hint_amount": HintAmount.default,
|
||||
"area_hint_percentage": AreaHintPercentage.default,
|
||||
"laser_hints": LaserHints.default,
|
||||
@@ -118,6 +122,8 @@ witness_option_presets: Dict[str, Dict[str, Any]] = {
|
||||
|
||||
"trap_percentage": TrapPercentage.default,
|
||||
"puzzle_skip_amount": 15,
|
||||
"trap_weights": TrapWeights.default,
|
||||
|
||||
"hint_amount": HintAmount.default,
|
||||
"area_hint_percentage": AreaHintPercentage.default,
|
||||
"laser_hints": LaserHints.default,
|
||||
|
Reference in New Issue
Block a user