WebHost now generates a weighted-settings.json file for use with the upcoming weighted-settings page.
This commit is contained in:
		
							parent
							
								
									d13b7988b7
								
							
						
					
					
						commit
						c550fdaee8
					
				| 
						 | 
					@ -27,7 +27,19 @@ def create():
 | 
				
			||||||
            return list(default_value)
 | 
					            return list(default_value)
 | 
				
			||||||
        return default_value
 | 
					        return default_value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    weighted_settings = {
 | 
				
			||||||
 | 
					        "baseOptions": {
 | 
				
			||||||
 | 
					            "description": "Generated by https://archipelago.gg/",
 | 
				
			||||||
 | 
					            "name": "Player",
 | 
				
			||||||
 | 
					            "game": {},
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "games": {},
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for game_name, world in AutoWorldRegister.world_types.items():
 | 
					    for game_name, world in AutoWorldRegister.world_types.items():
 | 
				
			||||||
 | 
					        if (world.hidden):
 | 
				
			||||||
 | 
					            continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        all_options = {**world.options, **Options.per_game_common_options}
 | 
					        all_options = {**world.options, **Options.per_game_common_options}
 | 
				
			||||||
        res = Template(open(os.path.join("WebHostLib", "templates", "options.yaml")).read()).render(
 | 
					        res = Template(open(os.path.join("WebHostLib", "templates", "options.yaml")).read()).render(
 | 
				
			||||||
            options=all_options,
 | 
					            options=all_options,
 | 
				
			||||||
| 
						 | 
					@ -88,3 +100,11 @@ def create():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with open(os.path.join(target_folder, 'player-settings', game_name + ".json"), "w") as f:
 | 
					        with open(os.path.join(target_folder, 'player-settings', game_name + ".json"), "w") as f:
 | 
				
			||||||
            f.write(json.dumps(player_settings, indent=2, separators=(',', ': ')))
 | 
					            f.write(json.dumps(player_settings, indent=2, separators=(',', ': ')))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        weighted_settings["baseOptions"]["game"][game_name] = 0
 | 
				
			||||||
 | 
					        weighted_settings["games"][game_name] = {}
 | 
				
			||||||
 | 
					        weighted_settings["games"][game_name]["gameOptions"] = game_options
 | 
				
			||||||
 | 
					        weighted_settings["games"][game_name]["gameItems"] = tuple(world.item_name_to_id.keys())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    with open(os.path.join(target_folder, 'weighted-settings.json'), "w") as f:
 | 
				
			||||||
 | 
					        f.write(json.dumps(weighted_settings, indent=2, separators=(',', ': ')))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue