X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=make_dungeon.py;h=e7e37ae2c6baeaa23177901de65824468e45d0c5;hb=refs%2Fmerge-requests%2F184%2Fhead;hp=b893e4b266cf6c8c862d04db450b8fda5ffcdde3;hpb=e57d9d514cc6cdeb23ddc995a4b9eb745f43817b;p=open-adventure.git diff --git a/make_dungeon.py b/make_dungeon.py index b893e4b..e7e37ae 100755 --- a/make_dungeon.py +++ b/make_dungeon.py @@ -144,6 +144,11 @@ typedef struct {{ const long message; }} action_t; +typedef struct {{ + const string_group_t words; + const char* message; +}} special_t; + typedef struct {{ const long motion; const long cond; @@ -172,7 +177,7 @@ extern const hint_t hints[]; extern long conditions[]; extern const motion_t motions[]; extern const action_t actions[]; -extern const action_t specials[]; +extern const special_t specials[]; extern const travelop_t travel[]; extern const long tkey[]; extern const char *ignore; @@ -263,7 +268,7 @@ const action_t actions[] = {{ {} }}; -const action_t specials[] = {{ +const special_t specials[] = {{ {} }}; @@ -558,6 +563,35 @@ def get_actions(actions): act_str = act_str[:-1] # trim trailing newline return act_str +def get_specials(specials): + template = """ {{ + .words = {}, + .message = {}, + }}, +""" + spc_str = "" + for special in specials: + contents = special[1] + + if contents["words"] == None: + words_str = get_string_group([]) + else: + words_str = get_string_group(contents["words"]) + + if contents["message"] == None: + message = "NULL" + else: + message = make_c_string(contents["message"]) + + spc_str += template.format(words_str, message) + global ignore + if contents.get("oldstyle", True) == False: + for word in contents["words"]: + if len(word) == 1: + ignore += word.upper() + spc_str = spc_str[:-1] # trim trailing newline + return spc_str + def bigdump(arr): out = "" for (i, entry) in enumerate(arr): @@ -724,7 +758,7 @@ if __name__ == "__main__": get_condbits(db["locations"]), get_motions(db["motions"]), get_actions(db["actions"]), - get_actions(db["specials"]), + get_specials(db["specials"]), bigdump(tkey), get_travel(travel), ignore,