projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Coverage fixups.
[open-adventure.git]
/
make_dungeon.py
diff --git
a/make_dungeon.py
b/make_dungeon.py
index 454a27a3c4ae81c69a226c11f3aaf7d37f155225..724b941d9652c10b824e1c9ec42486cd7a075a76 100755
(executable)
--- a/
make_dungeon.py
+++ b/
make_dungeon.py
@@
-1,4
+1,4
@@
-#!/usr/bin/env python
+#!/usr/bin/env python
3
# This is the open-adventure dungeon generator. It consumes a YAML description of
# the dungeon and outputs a dungeon.h and dungeon.c pair of C code files.
# This is the open-adventure dungeon generator. It consumes a YAML description of
# the dungeon and outputs a dungeon.h and dungeon.c pair of C code files.
@@
-6,6
+6,9
@@
# The nontrivial part of this is the compilation of the YAML for
# movement rules to the travel array that's actually used by
# playermove().
# The nontrivial part of this is the compilation of the YAML for
# movement rules to the travel array that's actually used by
# playermove().
+#
+# Copyright (c) 2017 by Eric S. Raymond
+# SPDX-License-Identifier: BSD-2-clause
import sys, yaml
import sys, yaml
@@
-152,8
+155,8
@@
def get_objects(obj):
if labels:
global statedefines
statedefines += "/* States for %s */\n" % item[0]
if labels:
global statedefines
statedefines += "/* States for %s */\n" % item[0]
- for (
j
, label) in enumerate(labels):
- statedefines += "#define %s\t%d\n" % (label,
j
)
+ for (
n
, label) in enumerate(labels):
+ statedefines += "#define %s\t%d\n" % (label,
n
)
statedefines += "\n"
sounds_str = ""
if attr.get("sounds") == None:
statedefines += "\n"
sounds_str = ""
if attr.get("sounds") == None:
@@
-203,7
+206,7
@@
def get_obituaries(obit):
obit_str = obit_str[:-1] # trim trailing newline
return obit_str
obit_str = obit_str[:-1] # trim trailing newline
return obit_str
-def get_hints(hnt
, arb
):
+def get_hints(hnt):
template = """ {{
.number = {},
.penalty = {},
template = """ {{
.number = {},
.penalty = {},
@@
-213,7
+216,6
@@
def get_hints(hnt, arb):
}},
"""
hnt_str = ""
}},
"""
hnt_str = ""
- md = dict(arb)
for member in hnt:
item = member["hint"]
number = item["number"]
for member in hnt:
item = member["hint"]
number = item["number"]
@@
-438,7
+440,7
@@
def buildtravel(locs, objs):
# At this point the ltravel data is in the Section 3
# representation from the FORTRAN version. Next we perform the
# At this point the ltravel data is in the Section 3
# representation from the FORTRAN version. Next we perform the
- # same mapping into w
g
at used to be the runtime format.
+ # same mapping into w
h
at used to be the runtime format.
travel = [[0, "LOC_NOWHERE", 0, 0, 0, 0, 0, 0, "false", "false"]]
tkey = [0]
travel = [[0, "LOC_NOWHERE", 0, 0, 0, 0, 0, 0, "false", "false"]]
tkey = [0]
@@
-521,7
+523,7
@@
def get_travel(travel):
if __name__ == "__main__":
with open(YAML_NAME, "r") as f:
if __name__ == "__main__":
with open(YAML_NAME, "r") as f:
- db = yaml.load(f)
+ db = yaml.
safe_
load(f)
locnames = [x[0] for x in db["locations"]]
msgnames = [el[0] for el in db["arbitrary_messages"]]
locnames = [x[0] for x in db["locations"]]
msgnames = [el[0] for el in db["arbitrary_messages"]]
@@
-550,7
+552,7
@@
if __name__ == "__main__":
locations = get_locations(db["locations"]),
objects = get_objects(db["objects"]),
obituaries = get_obituaries(db["obituaries"]),
locations = get_locations(db["locations"]),
objects = get_objects(db["objects"]),
obituaries = get_obituaries(db["obituaries"]),
- hints = get_hints(db["hints"]
, db["arbitrary_messages"]
),
+ hints = get_hints(db["hints"]),
conditions = get_condbits(db["locations"]),
motions = get_motions(db["motions"]),
actions = get_actions(db["actions"]),
conditions = get_condbits(db["locations"]),
motions = get_motions(db["motions"]),
actions = get_actions(db["actions"]),