3 # Enhance adventure.yaml entries with explicit object-sound properties
4 # based on Section 13 of adventure.text.
6 # When in doubt, make the code dumber and the data smarter.
10 # This is the original sound-attribute data from section 13 of adventure.text
35 if __name__ == "__main__":
36 with open("adventure.yaml", "r") as fp:
39 objnames = [el[0] for el in db["object_descriptions"]]
42 soundtrap = texttrap = None
47 if line.startswith("- OBJ"):
49 soundtrap = texttrap = None
50 for (obj, sound, text) in section13:
52 counter = -2 # Skip inventory and longs markup line
53 soundtrap = None if (sound == -1) else sound
54 texttrap = None if (text == -1) else text
57 sys.stdout.write(line)
58 if soundtrap is not None and counter == soundtrap:
59 sys.stdout.write(" sounds:\n")
60 if texttrap is not None and counter == texttrap:
61 sys.stdout.write(" texts:\n")