Merge remote-tracking branch 'origin/OverworldShuffle' into GwaaKiwi

This commit is contained in:
2025-09-01 11:03:25 -05:00
8 changed files with 174 additions and 16 deletions

View File

@@ -298,6 +298,11 @@ class CustomSettings(object):
if 'enemies' in self.file_source:
return self.file_source['enemies']
return None
def get_gtentry(self):
if 'gt_entry' in self.file_source:
return self.file_source['gt_entry']
return None
def get_attribute_by_player_composite(self, attribute, player):

View File

@@ -16,6 +16,16 @@ def get_weights(path):
return yaml.load(urllib.request.urlopen(path), Loader=yaml.FullLoader)
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):
root = weights if root is None else root
if option not in root:
@@ -65,16 +75,6 @@ def roll_settings(weights):
return default
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.algorithm = get_choice('algorithm')