Skip to content

Commit df66d5f

Browse files
output usable files for each game and rename mystery.yaml to weights.yaml (ArchipelagoMW#165)
* output usable files for each game * mystery.yaml -> weights.yaml * do all the games output to a single file * don't put dashes after the final game * oop
1 parent 8468336 commit df66d5f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

GenerateMystery.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ def weight_percentages(self) -> dict:
3838
return games
3939

4040

41+
class GameSettings(MysterySettings):
42+
def __init__(self, name: str, description: str, requires: dict, game: str, game_options: dict):
43+
super().__init__(name, description, requires, game)
44+
45+
self[game] = game_options
46+
47+
4148
def main():
4249
# Create output directory, if it does not exist.
4350
if not os.path.exists("output/"):
@@ -97,9 +104,17 @@ def main():
97104
raise ValueError(f"Could not find `{game}` top-level key in `{meta_path}`")
98105
meta.update(meta_settings)
99106

100-
with open("output/mystery.yaml", "w+") as file:
107+
with open("output/weights.yaml", "w+") as file:
101108
yaml.dump(dict(mystery), file)
102-
print(Fore.GREEN + "\nOutputted settings file to `./output/mystery.yaml`")
109+
with open("output/games.yaml", "w+") as file:
110+
games = list(mystery["game"])
111+
last_key = games[-1]
112+
for game in games:
113+
game_options = GameSettings(mystery["name"], mystery["description"], mystery["requires"], game, mystery[game])
114+
yaml.dump(dict(game_options), file)
115+
if game != last_key:
116+
file.write("\n---\n\n")
117+
print(Fore.GREEN + "\nOutputted settings file to `./output/weights.yaml`")
103118
meta_path = os.path.join("output", "meta.yaml")
104119
with open(meta_path, "w+") as file:
105120
yaml.dump(meta, file)

0 commit comments

Comments
 (0)