X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=make_graph.py;h=e90dc5a98d7c5f97efff6c8a410d0d8f8e609b0e;hb=8b8a3a73c4812af90bdd755c35f6c4e001553872;hp=28af8f7d23c328cf76cf4f2bbd986ce3d83719ed;hpb=07f77a8ffd7e9f1dfdd09fe534323d3d1b206df7;p=open-adventure.git diff --git a/make_graph.py b/make_graph.py index 28af8f7..e90dc5a 100755 --- a/make_graph.py +++ b/make_graph.py @@ -7,9 +7,13 @@ import sys, yaml -def allalike(loc): +def allalike(loc, dest): "Select out loci related to the Maze All Alike" - return (loc == "LOC_MISTWEST") or ("ALIKE" in loc) or ("DEADEND" in loc) or ("STALACTITE" in loc) + return ("ALIKE" in loc) or ("MAZEEND" in loc) or ("STALACTITE" in loc) or (loc == "LOC_MISTWEST" and "ALIKE" in dest) + +def abbreviate(d): + m = {"NORTH":"N", "EAST":"E", "SOUTH":"S", "WEST":"W", "UPWAR":"U", "DOWN":"D"} + return m.get(d, d) if __name__ == "__main__": with open("adventure.yaml", "r") as f: @@ -17,17 +21,18 @@ if __name__ == "__main__": print("digraph G {") for (loc, attrs) in db["locations"]: - if not allalike(loc): - continue travel = attrs["travel"] if len(travel) > 0: for dest in travel: - verbs = dest["verbs"] + verbs = [abbreviate(x) for x in dest["verbs"]] if len(verbs) == 0: continue action = dest["action"] if action[0] == "goto": - arc = "%s -> %s" % (loc[4:], action[1][4:]) + dest = action[1] + if not allalike(loc, dest): + continue; + arc = "%s -> %s" % (loc[4:], dest[4:]) label=",".join(verbs).lower() if len(label) > 0: arc += ' [label="%s"]' % label