X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=new2%2Fplomrogue%2Fmapping.py;h=585000a1d0f471dfd8b4b5d2c0a3f6ecccb39445;hb=09a7a28a19b56662eccceb5785fd36265845c15c;hp=aa5af2c6778c33444e51de1f74236e61a8442838;hpb=e1d03eb7d5f847813071e1711accbb4d9153fdcf;p=plomrogue2-experiments
diff --git a/new2/plomrogue/mapping.py b/new2/plomrogue/mapping.py
index aa5af2c..585000a 100644
--- a/new2/plomrogue/mapping.py
+++ b/new2/plomrogue/mapping.py
@@ -17,6 +17,9 @@ class YX(collections.namedtuple('YX', ('y', 'x'))):
class MapGeometry():
+ def __init__(self, size):
+ self.size = size
+
def get_directions(self):
directions = []
for name in dir(self):
@@ -26,7 +29,11 @@ class MapGeometry():
def move(self, start_pos, direction):
mover = getattr(self, 'move_' + direction)
- return mover(start_pos)
+ target = mover(start_pos)
+ if target.y < 0 or target.x < 0 or \
+ target.y >= self.size.y or target.x >= self.size.x:
+ return None
+ return target