Use YAML references to tie hints to locations.
[open-adventure.git] / newdungeon.py
index 52380e6705c55a5774c15055c5d079eca892f084..193fe03afffbe49abfc359b02959f55320cbc9f9 100755 (executable)
@@ -9,6 +9,8 @@ h_name = "newdb.h"
 c_name = "newdb.c"
 
 h_template = """/* Generated from adventure.yaml - do not hand-hack! */
+#ifndef NEWDB_H
+#define NEWDB_H
 
 #include <stdio.h>
 
@@ -61,6 +63,7 @@ extern hint_t hints[];
 extern const size_t CLSSES;
 extern const int maximum_deaths;
 extern const int turn_threshold_count;
+#define HINT_COUNT {}
 
 enum arbitrary_messages_refs {{
 {}
@@ -74,7 +77,7 @@ enum object_descriptions_refs {{
 {}
 }};
 
-/* end */
+#endif /* end NEWDB_H */
 """
 
 c_template = """/* Generated from adventure.yaml - do not hand-hack! */
@@ -237,7 +240,8 @@ def get_hints(hnt, arb):
 """
     hnt_str = ""
     md = dict(arb)
-    for item in hnt:
+    for member in hnt:
+        item = member["hint"]
         number = item["number"]
         penalty = item["penalty"]
         turns = item["turns"]
@@ -253,6 +257,7 @@ if __name__ == "__main__":
         db = yaml.load(f)
 
     h = h_template.format(
+        len(db["hints"]),
         get_refs(db["arbitrary_messages"]),
         get_refs(db["locations"]),
         get_refs(db["object_descriptions"]),