X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=newdungeon.py;h=092c342e52038588bc08550cc985fb3bbca5e4d0;hb=537c4511e2f3802421f79aed7b6af16d66adb518;hp=52380e6705c55a5774c15055c5d079eca892f084;hpb=c3a71f6db6781e40a9e75bb1107c901d791aab04;p=open-adventure.git diff --git a/newdungeon.py b/newdungeon.py index 52380e6..092c342 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -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 @@ -57,10 +59,12 @@ extern const class_t classes[]; 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; extern const int turn_threshold_count; +#define HINT_COUNT {} enum arbitrary_messages_refs {{ {} @@ -74,11 +78,12 @@ enum object_descriptions_refs {{ {} }}; -/* end */ +#endif /* end NEWDB_H */ """ c_template = """/* Generated from adventure.yaml - do not hand-hack! */ +#include "common.h" #include "{}" const char* arbitrary_messages[] = {{ @@ -109,6 +114,10 @@ hint_t hints[] = {{ {} }}; +const long conditions[] = {{ +{} +}}; + const size_t CLSSES = {}; const int maximum_deaths = {}; const int turn_threshold_count = {}; @@ -237,7 +246,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"] @@ -247,12 +257,32 @@ def get_hints(hnt, arb): 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<