Skip to content

Commit

Permalink
output usable files for each game and rename mystery.yaml to weights.…
Browse files Browse the repository at this point in the history
…yaml (#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
  • Loading branch information
alwaysintreble authored Jul 24, 2024
1 parent 8468336 commit df66d5f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions GenerateMystery.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def weight_percentages(self) -> dict:
return games


class GameSettings(MysterySettings):
def __init__(self, name: str, description: str, requires: dict, game: str, game_options: dict):
super().__init__(name, description, requires, game)

self[game] = game_options


def main():
# Create output directory, if it does not exist.
if not os.path.exists("output/"):
Expand Down Expand Up @@ -97,9 +104,17 @@ def main():
raise ValueError(f"Could not find `{game}` top-level key in `{meta_path}`")
meta.update(meta_settings)

with open("output/mystery.yaml", "w+") as file:
with open("output/weights.yaml", "w+") as file:
yaml.dump(dict(mystery), file)
print(Fore.GREEN + "\nOutputted settings file to `./output/mystery.yaml`")
with open("output/games.yaml", "w+") as file:
games = list(mystery["game"])
last_key = games[-1]
for game in games:
game_options = GameSettings(mystery["name"], mystery["description"], mystery["requires"], game, mystery[game])
yaml.dump(dict(game_options), file)
if game != last_key:
file.write("\n---\n\n")
print(Fore.GREEN + "\nOutputted settings file to `./output/weights.yaml`")
meta_path = os.path.join("output", "meta.yaml")
with open(meta_path, "w+") as file:
yaml.dump(meta, file)
Expand Down

0 comments on commit df66d5f

Please sign in to comment.