From: Neil Date: Mon, 15 Apr 2013 12:39:42 +0000 (+0200) Subject: Add blocked check to level X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=49aebbc4ef4ba436f5a8fc3f72e1982b4c79b51b;p=erdslangetjie.git Add blocked check to level --- diff --git a/erdslangetjie/level.py b/erdslangetjie/level.py index 7905571..4dffd6d 100644 --- a/erdslangetjie/level.py +++ b/erdslangetjie/level.py @@ -44,3 +44,16 @@ class Level(object): def at_exit(self, pos): return pos in self.exit_pos + + def blocked(self, pos): + if pos[0] < 0: + return True + if pos[1] < 0: + return True + try: + tile = self.data[pos[1]][pos[0]] + except IndexError: + return True + if tile == '.': + return True + return False