projects
/
open-adventure.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9301a4f
)
A step forward in definining YAML for the travel array.
author
Eric S. Raymond
<esr@thyrsus.com>
Sun, 25 Jun 2017 18:46:01 +0000
(14:46 -0400)
committer
Eric S. Raymond
<esr@thyrsus.com>
Sun, 25 Jun 2017 23:22:46 +0000
(19:22 -0400)
travel.py
patch
|
blob
|
history
diff --git
a/travel.py
b/travel.py
index c9731eb7e2a812ff448c1e89f3a59e416a694dbd..3d6acf576eae29dee2446afe0fcba4474b1d3cdd 100755
(executable)
--- a/
travel.py
+++ b/
travel.py
@@
-42,6
+42,9
@@
# This says that, from 11, 49 takes him to 8 unless game.prop(3)=0, in which
# case he goes to 9. Verb 50 takes him to 9 regardless of game.prop(3).
#
# This says that, from 11, 49 takes him to 8 unless game.prop(3)=0, in which
# case he goes to 9. Verb 50 takes him to 9 regardless of game.prop(3).
#
+# In addition, it looks as though the action verb value 1 is a sentinel used
+# when a table entry would have no motions at all in it.
+#
import sys, yaml
# This is the original travel table from section 3 of adventure.text
import sys, yaml
# This is the original travel table from section 3 of adventure.text
@@
-688,9
+691,17
@@
def genline(loc):
src = t.pop(0)
if src == loc:
dest = t.pop(0)
src = t.pop(0)
if src == loc:
dest = t.pop(0)
+ try:
+ if t.index(1) == len(t) - 1:
+ t.pop()
+ else:
+ sys.stderr.write("%s (%d): action value 1 in unexpected place\n" %\
+ (locnames[loc], loc))
+ sys.exit(1)
+ except ValueError:
+ pass
cond = dest // 1000
dest = dest % 1000
cond = dest // 1000
dest = dest % 1000
- print("cond %s, dest %s, words: %s" % (cond, dest, t))
t = [verbs[e] for e in t]
sys.stdout.write(" %s %s %s,\n" % (destdecode(dest), cond, t))
sys.stdout.write(" }\n")
t = [verbs[e] for e in t]
sys.stdout.write(" %s %s %s,\n" % (destdecode(dest), cond, t))
sys.stdout.write(" }\n")
@@
-707,7
+718,6
@@
if __name__ == "__main__":
for entry in db["vocabulary"]:
if entry["type"] == "motion" and entry["value"] not in verbs:
verbs[entry["value"]] = entry["word"]
for entry in db["vocabulary"]:
if entry["type"] == "motion" and entry["value"] not in verbs:
verbs[entry["value"]] = entry["word"]
- print(verbs)
ln = -1
while True:
line = fp.readline()
ln = -1
while True:
line = fp.readline()