Fix issue with Mystery subweights not correctly evaluating boolean settings

This commit is contained in:
codemann8
2025-08-25 12:31:11 -05:00
parent 802a75c2a3
commit b80bed0853

View File

@@ -16,6 +16,16 @@ def get_weights(path):
return yaml.load(urllib.request.urlopen(path), Loader=yaml.FullLoader) return yaml.load(urllib.request.urlopen(path), Loader=yaml.FullLoader)
def roll_settings(weights): def roll_settings(weights):
while True:
subweights = weights.get('subweights', {})
if len(subweights) == 0:
break
chances = ({k: int(v['chance']) for (k, v) in subweights.items()})
subweight_name = random.choices(list(chances.keys()), weights=list(chances.values()))[0]
subweights = weights.get('subweights', {}).get(subweight_name, {}).get('weights', {})
subweights['subweights'] = subweights.get('subweights', {})
weights = {**weights, **subweights}
def get_choice(option, root=None): def get_choice(option, root=None):
root = weights if root is None else root root = weights if root is None else root
if option not in root: if option not in root:
@@ -65,16 +75,6 @@ def roll_settings(weights):
return default return default
return choice return choice
while True:
subweights = weights.get('subweights', {})
if len(subweights) == 0:
break
chances = ({k: int(v['chance']) for (k, v) in subweights.items()})
subweight_name = random.choices(list(chances.keys()), weights=list(chances.values()))[0]
subweights = weights.get('subweights', {}).get(subweight_name, {}).get('weights', {})
subweights['subweights'] = subweights.get('subweights', {})
weights = {**weights, **subweights}
ret = argparse.Namespace() ret = argparse.Namespace()
ret.algorithm = get_choice('algorithm') ret.algorithm = get_choice('algorithm')