X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=newdungeon.py;h=4553eea5d8e25482d2c7fffaadbd0d69dfbc7b08;hp=624ea865ed30f8f5901701199a25a2f99aad0eb4;hb=f47dc9f44798e3d03e4760c8b53b44c7de4c92f9;hpb=98b7434b0b67185c52ba388abc549386d819acd7 diff --git a/newdungeon.py b/newdungeon.py index 624ea86..4553eea 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -14,6 +14,8 @@ h_template = """/* Generated from adventure.yaml - do not hand-hack! */ #include +#define SILENT -1 /* no sound */ + typedef struct {{ const char* inventory; const char** longs; @@ -26,6 +28,7 @@ typedef struct {{ typedef struct {{ descriptions_t description; + const long sound; }} location_t; typedef struct {{ @@ -189,13 +192,15 @@ def get_locations(loc): .small = {}, .big = {}, }}, + .sound = {}, }}, """ loc_str = "" for item in loc: short_d = make_c_string(item[1]["description"]["short"]) long_d = make_c_string(item[1]["description"]["long"]) - loc_str += template.format(short_d, long_d) + sound = item[1].get("sound", "SILENT") + loc_str += template.format(short_d, long_d, sound) loc_str = loc_str[:-1] # trim trailing newline return loc_str