X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=newdungeon.py;h=7f37b36f82b2c2af8dfe46be24ac732244588fe7;hb=a76cbeccbb1e7d957cf7036a7125abb48f22eb9d;hp=8974a5abbf1395e80dc93bc500acddbb00724ae3;hpb=64959e4bcea15ac3e561961f50291e1d2807f800;p=open-adventure.git diff --git a/newdungeon.py b/newdungeon.py index 8974a5a..7f37b36 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -92,6 +92,11 @@ typedef struct {{ const char** words; }} motion_t; +typedef struct {{ + const char** words; + const long message; +}} action_t; + extern const location_t locations[]; extern const object_t objects[]; extern const char* arbitrary_messages[]; @@ -102,6 +107,7 @@ extern const hint_t hints[]; extern long conditions[]; extern const long actspk[]; extern const motion_t motions[]; +extern const action_t actions[]; #define NLOCATIONS {} #define NOBJECTS {} @@ -109,7 +115,7 @@ extern const motion_t motions[]; #define NCLASSES {} #define NDEATHS {} #define NTHRESHOLDS {} -#define NVERBS {} +#define NACTIONS {} #define NTRAVEL {} enum arbitrary_messages_refs {{ @@ -128,6 +134,10 @@ enum motion_refs {{ {} }}; +enum action_refs {{ +{} +}}; + /* State definitions */ {} @@ -180,6 +190,10 @@ const motion_t motions[] = {{ {} }}; +const action_t actions[] = {{ +{} +}}; + /* end */ """ @@ -484,6 +498,31 @@ def get_motions(motions): mot_str += template.format(words_str) return mot_str +def get_actions(actions): + template = """ {{ + .words = {}, + .message = {}, + }}, +""" + act_str = "" + for action in actions: + contents = action[1] + + if contents["words"] == None: + words_str = "NULL" + else: + c_words = [make_c_string(s) for s in contents["words"]] + words_str = "(const char* []) {" + ", ".join(c_words) + "}" + + if contents["message"] == None: + message = "NO_MESSAGE" + else: + message = contents["message"] + + act_str += template.format(words_str, message) + act_str = act_str[:-1] # trim trailing newline + return act_str + if __name__ == "__main__": with open(yaml_name, "r") as f: db = yaml.load(f) @@ -506,6 +545,7 @@ if __name__ == "__main__": get_condbits(db["locations"]), get_actspk(db["actspk"]), get_motions(db["motions"]), + get_actions(db["actions"]), ) h = h_template.format( @@ -521,6 +561,7 @@ if __name__ == "__main__": get_refs(db["locations"]), get_refs(db["objects"]), get_refs(db["motions"]), + get_refs(db["actions"]), statedefines, )