extern turn_threshold_t turn_thresholds[];
extern obituary_t obituaries[];
extern hint_t hints[];
+extern const long conditions[];
extern const size_t CLSSES;
extern const int maximum_deaths;
c_template = """/* Generated from adventure.yaml - do not hand-hack! */
+#include "common.h"
#include "{}"
const char* arbitrary_messages[] = {{
{}
}};
+const long conditions[] = {{
+{}
+}};
+
const size_t CLSSES = {};
const int maximum_deaths = {};
const int turn_threshold_count = {};
hnt_str = hnt_str[:-1] # trim trailing newline
return hnt_str
+def get_condbits(locations):
+ cnd_str = ""
+ for (name, loc) in locations:
+ conditions = loc["conditions"]
+ hints = loc.get("hints") or []
+ flaglist = []
+ for flag in conditions:
+ if conditions[flag]:
+ flaglist.append(flag)
+ line = "|".join([("(1<<COND_%s)" % f) for f in flaglist])
+ trail = "|".join([("(1<<COND_H%s)" % f['name']) for f in hints])
+ if trail:
+ line += "|" + trail
+ if line.startswith("|"):
+ line = line[1:]
+ if not line:
+ line = "0"
+ cnd_str += " " + line + ",\t// " + name + "\n"
+ return cnd_str
if __name__ == "__main__":
with open(yaml_name, "r") as f:
get_object_descriptions(db["object_descriptions"]),
get_obituaries(db["obituaries"]),
get_hints(db["hints"], db["arbitrary_messages"]),
+ get_condbits(db["locations"]),
len(db["classes"]),
len(db["obituaries"]),
len(db["turn_thresholds"]),