mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Mystery: can now roll for starting inventory items, eg:
startinventory: Pegasus Boots: 'on': 1 'off': 0 Bombs (3): 'on': 1 'off': 1
This commit is contained in:
11
Mystery.py
11
Mystery.py
@@ -109,8 +109,8 @@ def get_weights(path):
|
|||||||
return parse_yaml(yaml)
|
return parse_yaml(yaml)
|
||||||
|
|
||||||
def roll_settings(weights):
|
def roll_settings(weights):
|
||||||
def get_choice(option):
|
def get_choice(option, root=weights):
|
||||||
return random.choices(list(weights[option].keys()), weights=list(map(int,weights[option].values())))[0].replace('"','').replace("'",'')
|
return random.choices(list(root[option].keys()), weights=list(map(int,root[option].values())))[0].replace('"','').replace("'",'')
|
||||||
|
|
||||||
ret = argparse.Namespace()
|
ret = argparse.Namespace()
|
||||||
|
|
||||||
@@ -202,6 +202,13 @@ def roll_settings(weights):
|
|||||||
|
|
||||||
ret.beemizer = int(get_choice('beemizer')) if 'beemizer' in weights.keys() else 1 # suck it :)
|
ret.beemizer = int(get_choice('beemizer')) if 'beemizer' in weights.keys() else 1 # suck it :)
|
||||||
|
|
||||||
|
inventoryweights = weights.get('startinventory', {})
|
||||||
|
startitems = []
|
||||||
|
for item in inventoryweights.keys():
|
||||||
|
if get_choice(item, inventoryweights) == 'on':
|
||||||
|
startitems.append(item)
|
||||||
|
ret.startinventory = ','.join(startitems)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user