This version of newdungeon.py can exactly recover Section 3...

...from the YAML data. Next, to pack the recovered data the way
dungeon.c does and wite it in.
This commit is contained in:
Eric S. Raymond 2017-06-26 22:41:57 -04:00
parent f9edfc5151
commit 64959e4bce

View file

@ -465,8 +465,8 @@ def buildtravel(locs, objs, voc):
tt += [verbmap[e] for e in rule["verbs"]] tt += [verbmap[e] for e in rule["verbs"]]
if not rule["verbs"]: if not rule["verbs"]:
tt.append(1) tt.append(1)
#print(tuple(tt)) ltravel.append(tuple(tt))
return (ltravel, lkeys) return (tuple(ltravel), lkeys)
def get_motions(motions): def get_motions(motions):
template = """ {{ template = """ {{
@ -492,6 +492,7 @@ if __name__ == "__main__":
msgnames = [el[0] for el in db["arbitrary_messages"]] msgnames = [el[0] for el in db["arbitrary_messages"]]
objnames = [el[0] for el in db["objects"]] objnames = [el[0] for el in db["objects"]]
(travel, key) = buildtravel(db["locations"], db["objects"], db["vocabulary"]) (travel, key) = buildtravel(db["locations"], db["objects"], db["vocabulary"])
# FIXME: pack the Section 3 representation into the runtime format.
c = c_template.format( c = c_template.format(
h_name, h_name,