From f9edfc51515853c21418c1d55b681a71681a748c Mon Sep 17 00:00:00 2001 From: "Jason S. Ninneman" Date: Mon, 26 Jun 2017 22:22:51 -0400 Subject: [PATCH] Reexpress the motion words in adventure.yaml. --- advent.h | 8 --- adventure.yaml | 156 +++++++++++++++++++++++++++++++++++++++++++++++++ cheat.c | 8 --- init.c | 12 +--- main.c | 8 --- newdungeon.py | 55 ++++++++--------- 6 files changed, 185 insertions(+), 62 deletions(-) diff --git a/advent.h b/advent.h index 754ea16..4c31465 100644 --- a/advent.h +++ b/advent.h @@ -167,17 +167,9 @@ extern int restore(FILE *); #define INDEEP(LOC) ((LOC) >= LOC_MISTHALL && !OUTSID(LOC)) /* vocabulary items */ -extern long NUL; -extern long BACK; -extern long LOOK; -extern long CAVE; extern long FIND; extern long INVENT; extern long SAY; -extern long ENTER; -extern long STREAM; -extern long DPRSSN; -extern long ENTRNC; extern long LOCK; extern long THROW; diff --git a/adventure.yaml b/adventure.yaml index 10c083f..df5dfc7 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -378,6 +378,162 @@ actspk: { 35: HUH_MAN, } +motions: !!omap +- MOT_0: + words: !!null +- MOT_1: + words: !!null +- MOT_2: + words: ['road', 'hill'] +- ENTER: + words: ['enter'] +- MOT_4: + words: ['upstr'] +- MOT_5: + words: ['downs'] +- MOT_6: + words: ['fores'] +- MOT_7: + words: ['forwa', 'conti', 'onwar'] +- BACK: + 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'] +- STREAM: + 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'] +- NUL: + 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'] +- LOOK: + 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'] +- DPRSSN: + words: ['depre'] +- ENTRNC: + words: ['entra'] +- MOT_65: + words: ['plugh'] +- MOT_66: + words: ['secre'] +- CAVE: + words: ['cave'] +- MOT_68: + words: !!null +- 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/cheat.c b/cheat.c index 2cf3324..89b9201 100644 --- a/cheat.c +++ b/cheat.c @@ -13,17 +13,9 @@ struct game_t game; long LNLENG, LNPOSN; char rawbuf[LINESIZE], INLINE[LINESIZE + 1]; -long NUL; -long BACK; -long LOOK; -long CAVE; long FIND; long INVENT; long SAY; -long ENTER; -long STREAM; -long DPRSSN; -long ENTRNC; long LOCK; long THROW; diff --git a/init.c b/init.c index 129d17f..0ac3c4d 100644 --- a/init.c +++ b/init.c @@ -74,17 +74,7 @@ void initialise(void) /* Define some handy mnemonics. */ - /* These are motion-verb numbers. */ - BACK = VOCWRD(WORD_BACK, 0); - CAVE = VOCWRD(WORD_CAVE, 0); - DPRSSN = VOCWRD(WORD_DPRSSN, 0); - ENTER = VOCWRD(WORD_ENTER, 0); - ENTRNC = VOCWRD(WORD_ENTRNC, 0); - LOOK = VOCWRD(WORD_LOOK, 0); - NUL = VOCWRD(WORD_NUL, 0); - STREAM = VOCWRD(WORD_STREAM, 0); - - /* And some action verbs. */ + /* Some action verbs. */ FIND = VOCWRD(WORD_FIND, 2); INVENT = VOCWRD(WORD_INVENT, 2); LOCK = VOCWRD(WORD_LOCK, 2); diff --git a/main.c b/main.c index b598124..c02bd3c 100644 --- a/main.c +++ b/main.c @@ -43,17 +43,9 @@ struct game_t game; long LNLENG, LNPOSN; char rawbuf[LINESIZE], INLINE[LINESIZE + 1]; -long NUL; -long BACK; -long LOOK; -long CAVE; long FIND; long INVENT; long SAY; -long ENTER; -long STREAM; -long DPRSSN; -long ENTRNC; long LOCK; long THROW; diff --git a/newdungeon.py b/newdungeon.py index 7467475..64592e5 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -89,10 +89,8 @@ typedef struct {{ }} hint_t; typedef struct {{ - const char* word; - const int type; - const int value; -}} vocabulary_t; + const char** words; +}} motion_t; extern const location_t locations[]; extern const object_t objects[]; @@ -102,8 +100,8 @@ extern const turn_threshold_t turn_thresholds[]; extern const obituary_t obituaries[]; 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 {} @@ -112,7 +110,6 @@ extern const long actspk[]; #define NDEATHS {} #define NTHRESHOLDS {} #define NVERBS {} -#define NVOCAB {} #define NTRAVEL {} enum arbitrary_messages_refs {{ @@ -127,6 +124,10 @@ enum object_refs {{ {} }}; +enum motion_refs {{ +{} +}}; + /* State definitions */ {} @@ -170,12 +171,12 @@ long conditions[] = {{ {} }}; -const vocabulary_t vocabulary[] = {{ +const long actspk[] = {{ + NO_MESSAGE, {} }}; -const long actspk[] = {{ - NO_MESSAGE, +const motion_t motions[] = {{ {} }}; @@ -397,22 +398,6 @@ def recompose(type_word, value): sys.stderr.write("%s is not a known word classifier\n" % attrs["type"]) sys.exit(1) -def get_vocabulary(vocabulary): - template = """ {{ - .word = {}, - .type = {}, - .value = {}, - }}, -""" - voc_str = "" - for vocab in vocabulary: - word = make_c_string(vocab["word"]) - type_code = recompose(vocab["type"], vocab["value"]) - value = vocab["value"] - voc_str += template.format(word, type_code, value) - voc_str = voc_str[:-1] # trim trailing newline - return voc_str - def get_actspk(actspk): res = "" for (i, word) in actspk.items(): @@ -483,6 +468,22 @@ def buildtravel(locs, objs, voc): #print(tuple(tt)) return (ltravel, lkeys) +def get_motions(motions): + template = """ {{ + .words = {}, + }}, +""" + mot_str = "" + for motion in motions: + contents = motion[1] + if contents["words"] == None: + mot_str += template.format("NULL") + continue + c_words = [make_c_string(s) for s in contents["words"]] + words_str = "(const char* []) {" + ", ".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) @@ -502,8 +503,8 @@ if __name__ == "__main__": get_obituaries(db["obituaries"]), get_hints(db["hints"], db["arbitrary_messages"]), get_condbits(db["locations"]), - get_vocabulary(db["vocabulary"]), get_actspk(db["actspk"]), + get_motions(db["motions"]), ) h = h_template.format( @@ -514,11 +515,11 @@ if __name__ == "__main__": len(db["obituaries"]), len(db["turn_thresholds"]), len(db["actspk"]), - len(db["vocabulary"]), len(travel), get_refs(db["arbitrary_messages"]), get_refs(db["locations"]), get_refs(db["objects"]), + get_refs(db["motions"]), statedefines, ) -- 2.31.1