From b9bfa744e11e3de871a6fc82e9cb01e513940334 Mon Sep 17 00:00:00 2001 From: "Jason S. Ninneman" Date: Mon, 26 Jun 2017 15:21:40 -0700 Subject: [PATCH] Reexpress the motion words in adventure.yaml. --- adventure.yaml | 156 +++++++++++++++++++++++++++++++++++++++++++++++++ newdungeon.py | 28 +++++++++ 2 files changed, 184 insertions(+) diff --git a/adventure.yaml b/adventure.yaml index 03f532a..42af7ae 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -378,6 +378,162 @@ actspk: { 35: HUH_MAN, } +motions: !!omap +- MOT_0: + words: [] +- MOT_1: + words: [] +- MOT_2: + words: ['road', 'hill'] +- MOT_3: + words: ['enter'] +- MOT_4: + words: ['upstr'] +- MOT_5: + words: ['downs'] +- MOT_6: + words: ['fores'] +- MOT_7: + words: ['forwa', 'conti', 'onwar'] +- MOT_8: + words: ['back', 'retur', 'retre'] +- MOT_9: + words: ['valle'] +- MOT_10: + words: ['stair'] +- MOT_11: + words: ['out', 'outsi', 'exit', 'leave'] +- MOT_12: + words: ['build', 'house'] +- MOT_13: + words: ['gully'] +- MOT_14: + words: ['strea'] +- MOT_15: + words: ['fork'] +- MOT_16: + words: ['bed'] +- MOT_17: + words: ['crawl'] +- MOT_18: + words: ['cobbl'] +- MOT_19: + words: ['inwar', 'insid', 'in'] +- MOT_20: + words: ['surfa'] +- MOT_21: + words: ['null', 'nowhe'] +- MOT_22: + words: ['dark'] +- MOT_23: + words: ['passa', 'tunne'] +- MOT_24: + words: ['low'] +- MOT_25: + words: ['canyo'] +- MOT_26: + words: ['awkwa'] +- MOT_27: + words: ['giant'] +- MOT_28: + words: ['view'] +- MOT_29: + words: ['upwar', 'up', 'u', 'above', 'ascen'] +- MOT_30: + words: ['d', 'downw', 'down', 'desce'] +- MOT_31: + words: ['pit'] +- MOT_32: + words: ['outdo'] +- MOT_33: + words: ['crack'] +- MOT_34: + words: ['steps'] +- MOT_35: + words: ['dome'] +- MOT_36: + words: ['left'] +- MOT_37: + words: ['right'] +- MOT_38: + words: ['hall'] +- MOT_39: + words: ['jump'] +- MOT_40: + words: ['barre'] +- MOT_41: + words: ['over'] +- MOT_42: + words: ['acros'] +- MOT_43: + words: ['east', 'e'] +- MOT_44: + words: ['west', 'w'] +- MOT_45: + words: ['north', 'n'] +- MOT_46: + words: ['south', 's'] +- MOT_47: + words: ['ne'] +- MOT_48: + words: ['se'] +- MOT_49: + words: ['sw'] +- MOT_50: + words: ['nw'] +- MOT_51: + words: ['debri'] +- MOT_52: + words: ['hole'] +- MOT_53: + words: ['wall'] +- MOT_54: + words: ['broke'] +- MOT_55: + words: ['y2'] +- MOT_56: + words: ['climb'] +- MOT_57: + words: ['look', 'exami', 'touch', 'descr'] +- MOT_58: + words: ['floor'] +- MOT_59: + words: ['room'] +- MOT_60: + words: ['slit'] +- MOT_61: + words: ['slab', 'slabr'] +- MOT_62: + words: ['xyzzy'] +- MOT_63: + words: ['depre'] +- MOT_64: + words: ['entra'] +- MOT_65: + words: ['plugh'] +- MOT_66: + words: ['secre'] +- MOT_67: + words: ['cave'] +- MOT_68: + words: [] +- MOT_69: + words: ['cross'] +- MOT_70: + words: ['bedqu'] +- MOT_71: + words: ['plove'] +- MOT_72: + words: ['orien'] +- MOT_73: + words: ['caver'] +- MOT_74: + words: ['shell'] +- MOT_75: + words: ['reser'] +- MOT_76: + words: ['main', 'offic'] + hints: - hint: &grate name: CAVE diff --git a/newdungeon.py b/newdungeon.py index bbfc0c8..6cc2c03 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -94,6 +94,10 @@ typedef struct {{ const int value; }} vocabulary_t; +typedef struct {{ + const char** words; +}} motion_t; + extern const location_t locations[]; extern const object_t objects[]; extern const char* arbitrary_messages[]; @@ -104,6 +108,7 @@ extern const hint_t hints[]; extern long conditions[]; extern const vocabulary_t vocabulary[]; extern const long actspk[]; +extern const motion_t motions[]; #define NLOCATIONS {} #define NOBJECTS {} @@ -126,6 +131,10 @@ enum object_refs {{ {} }}; +enum motion_refs {{ +{} +}}; + /* State definitions */ {} @@ -178,6 +187,10 @@ const long actspk[] = {{ {} }}; +const motion_t motions[] = {{ +{} +}}; + /* end */ """ @@ -418,6 +431,19 @@ def get_actspk(actspk): res += " %s,\n" % word return res +def get_motions(motions): + template = """ {{ + .words = (const char* []) {{{}}}, + }}, +""" + mot_str = "" + for motion in motions: + contents = motion[1] + c_words = [make_c_string(s) for s in contents["words"]] + words_str = ", ".join(c_words) + mot_str += template.format(words_str) + return mot_str + if __name__ == "__main__": with open(yaml_name, "r") as f: db = yaml.load(f) @@ -436,6 +462,7 @@ if __name__ == "__main__": get_condbits(db["locations"]), get_vocabulary(db["vocabulary"]), get_actspk(db["actspk"]), + get_motions(db["motions"]), ) h = h_template.format( @@ -450,6 +477,7 @@ if __name__ == "__main__": get_refs(db["arbitrary_messages"]), get_refs(db["locations"]), get_refs(db["objects"]), + get_refs(db["motions"]), statedefines, )