Mystery: weights can now specify a default value for convenience, eg:

dungeon_items: full
startinventory:
  Pegasus Boots: on
This commit is contained in:
Bonta-kun 2020-01-06 20:01:03 +01:00
parent 7d05d697dd
commit 48305adaa0
1 changed files with 4 additions and 0 deletions

View File

@ -110,6 +110,10 @@ def get_weights(path):
def roll_settings(weights):
def get_choice(option, root=weights):
if type(root[option]) is not dict:
return root[option]
if not root[option]:
return None
return random.choices(list(root[option].keys()), weights=list(map(int,root[option].values())))[0].replace('"','').replace("'",'')
ret = argparse.Namespace()