Placeholder code for when Mordante's user-defined borders land.

This commit is contained in:
Eric S. Raymond 2007-09-22 12:15:45 +00:00
parent 1df7f27304
commit 704a2b2418

View file

@ -256,6 +256,7 @@ filemoves = {
("Halbardier" , "Halberdier"),
),
"1.3.7" : (),
"1.3.8" : (),
# An empty sentinel value at end is required.
"trunk" : (),
}
@ -448,6 +449,41 @@ def maptransform2(filename, baseline, inmap, y):
# There's only one kind of underground keep at present.
inmap[y][x] = inmap[y][x].replace("Ku", "Kud")
# The following two functions are not expected to work yet.
# They are placeholders for when Mordante's user-defined borders land.
def outermap(func, inmap):
"Apply a transformation based on neighborhood to the outermost ring."
for i in range(len(inmap[0])):
inmap[0][i] = func(neighborhood(i,0, inmap))
inmap[len(inmap[0])-1][i] = func(neighborhood(i,len(inmap[0])-1, inmap))
for i in range(1, len(inmap)-1):
inmap[i][0] = func(neighborhood(0,i, inmap))
inmap[i][len(inmap)-1] = func(neighborhood(len(inmap-1), i, inmap))
def maptransform3(filename, baseline, inmap, y):
"Add outer ring of inaccessible terrain to a map that doesn't have one."
if "off" in imap[0][0]: # If it already has an outer ring...
return # ...do nothing
# Start by duplicating the current outermost ring
inmap = [inmap[0]] + inmap + [inmap[-1]]
for i in range(len(inmap)):
inmap[i] = [inmap[i][0]] + inmap[i] + [inmap[i][-1]]
# Strip villages out of the edges
inmap = outermap(lambda n: re.sub(n[0], r"\^V[a-z]*", ""))
# Strip keeps out of the edges
inmap = outermap(lambda n: re.sub(n[0], r"K([a-z]*)", r"C\1"))
# Voidify problematic corners
for (y, x) in ((0, 0), (len(inmap)-1, 0),
(0, len(inmap[0])-1), (len(inmap)-1, len(inmap[0])-1)):
cn = neigborhood(x, y, inmap)
# All three neighbors must be equal, otherwise punt.
if cn[1] != cn[2] or cn[2] !=cn [3] or cn[3] !=cn [1]:
print "warning: voidifying corner %s[%d, %d]" % (filename, x, y)
inmap[y][x] = "_s"
# Finally, add the off-map prefix
inmap = outermap(lambda n: "off^" + n[0], inmap)
def validate_stack(stack, filename, lineno):
"Check the stack for deprecated WML syntax."
if verbose >= 3: