forked from choatix/Archipelago
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerateWithAlterations.py
77 lines (58 loc) · 2.84 KB
/
GenerateWithAlterations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import os
import sys
import yaml
import Generate
from Utils import parse_yaml
import CustomiseYaml
import settings
from worlds import network_data_package
settings = settings.get_settings()
names_only = False
if "generator" in settings:
generator_settings = settings["generator"]
if "names_only" in generator_settings:
names_only = generator_settings["names_only"] == 1
if "players_unmodified_path" in generator_settings:
unmodified_path = generator_settings["players_unmodified_path"]
players_path = generator_settings["player_files_path"]
files = os.listdir(unmodified_path)
for file in files:
unmodified_file = unmodified_path+"/"+file
end_file = players_path+"/"+file
if os.path.isfile(unmodified_file):
with (open(unmodified_file, encoding="utf-8-sig") as f):
options = parse_yaml(f.read())
game = options["game"]
game_options = options[game]
if names_only:
game_lookup = network_data_package["games"][game]
location_names = list(game_lookup["location_name_to_id"].keys())
print(location_names)
continue
if "alters" in game_options:
game_lookup = network_data_package["games"][game]
location_names = list(game_lookup["location_name_to_id"].keys())
#print(location_names)
alter_exclusions = {}
alter_priorities = {}
if "exclusions" in game_options["alters"]:
alter_exclusions = game_options["alters"]["exclusions"]
if "priorities" in game_options["alters"]:
alter_priorities = game_options["alters"]["priorities"]
print("Handling:", unmodified_file)
priorities,exclusions = CustomiseYaml\
.GetCustomWeightings(location_names, alter_priorities, alter_exclusions)
if "exclude_locations" not in game_options:
game_options["exclude_locations"] = []
game_options["exclude_locations"].extend(exclusions)
if "priority_locations" not in game_options:
game_options["priority_locations"] = []
game_options["priority_locations"].extend(priorities)
with open(end_file, "w") as yaml_file:
yaml.dump(options, yaml_file, default_flow_style=False)
print("test complete")
if names_only:
sys.exit(0)
#from Main import main as ERmain
#erargs, seed = Generate.main()
#multiworld = ERmain(erargs, seed)