home
·
contact
·
privacy
projects
/
plomrogue2-experiments
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More quote fixing.
[plomrogue2-experiments]
/
new2
/
plomrogue
/
mapping.py
diff --git
a/new2/plomrogue/mapping.py
b/new2/plomrogue/mapping.py
index 39aff658bee8682fa738244879166fe6f0c250fe..f056e105ca57a11d59b45d8451bada77211ef703 100644
(file)
--- a/
new2/plomrogue/mapping.py
+++ b/
new2/plomrogue/mapping.py
@@
-1,4
+1,5
@@
import collections
import collections
+from plomrogue.errors import ArgError
@@
-27,6
+28,12
@@
class MapGeometry():
directions += [name[5:]]
return directions
directions += [name[5:]]
return directions
+ def get_neighbors(self, pos):
+ neighbors = {}
+ for direction in self.get_directions():
+ neighbors[direction] = self.move(pos, direction)
+ return neighbors
+
def move(self, start_pos, direction):
mover = getattr(self, 'move_' + direction)
target = mover(start_pos)
def move(self, start_pos, direction):
mover = getattr(self, 'move_' + direction)
target = mover(start_pos)
@@
-83,8
+90,8
@@
class Map():
if y >= height_map:
raise ArgError('too large row number %s' % y)
width_line = len(line)
if y >= height_map:
raise ArgError('too large row number %s' % y)
width_line = len(line)
- if width_line
>
width_map:
- raise ArgError('
too large map line width %s' % width_line
)
+ if width_line
!=
width_map:
+ raise ArgError('
map line width %s unequal map width %s' % (width_line, width_map)
)
self.terrain = self.terrain[:y * width_map] + line +\
self.terrain[(y + 1) * width_map:]
self.terrain = self.terrain[:y * width_map] + line +\
self.terrain[(y + 1) * width_map:]