+def roomlabel(loc):
+ "Generate a room label from the description, if possible"
+ loc_descriptions = location_lookup[loc]['description']
+ description = ""
+ if debug:
+ description = loc[4:]
+ longd = loc_descriptions["long"]
+ short = loc_descriptions["maptag"] or loc_descriptions["short"]
+ if short is None and longd is not None and len(longd) < 20:
+ short = loc_descriptions["long"]
+ if short is not None:
+ if short.startswith("You're "):
+ short = short[7:]
+ if short.startswith("You are "):
+ short = short[8 :]
+ if short.startswith("in ") or short.startswith("at ") or short.startswith("on "):
+ short = short[3:]
+ if short.startswith("the "):
+ short = short[4:]
+ if short[:3] in {"n/s", "e/w"}:
+ short = short[:3].upper() + short[3:]
+ elif short[:2] in {"ne", "sw", "se", "nw"}:
+ short = short[:2].upper() + short[2:]
+ else:
+ short = short[0].upper() + short[1:]
+ if debug:
+ description += "\\n"
+ description += short
+ if loc in startlocs:
+ description += "\\n(" + ",".join(startlocs[loc]).lower() + ")"
+ return description
+
+# A forwarder is a location that you can't actually stop in - when you go there
+# it ships some message (which is the point) then shifts you to a next location.
+# A forwarder has a zero-length array of notion verbs in its travel section.
+#
+# Here is an example forwarder declaration:
+#
+# - LOC_GRUESOME:
+# description:
+# long: 'There is now one more gruesome aspect to the spectacular vista.'
+# short: !!null
+# maptag: !!null
+# conditions: {DEEP: true}
+# travel: [
+# {verbs: [], action: [goto, LOC_NOWHERE]},
+# ]
+
+def is_forwarder(loc):
+ "Is a location a forwarder?"
+ travel = location_lookup[loc]['travel']
+ return len(travel) == 1 and len(travel[0]['verbs']) == 0
+
+def forward(loc):
+ "Chase a location through forwarding links."
+ while is_forwarder(loc):
+ loc = location_lookup[loc]["travel"][0]["action"][1]
+ return loc
+
+def reveal(objname):
+ "Should this object be revealed when mapping?"
+ if "OBJ_" in objname:
+ return False
+ if objname == "VEND":
+ return True
+ obj = object_lookup[objname]
+ return not obj.get("immovable")
+