home · contact · privacy
Make some things block movement, and others not.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 13 Nov 2020 22:52:34 +0000 (23:52 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 13 Nov 2020 22:52:34 +0000 (23:52 +0100)
plomrogue/tasks.py
plomrogue/things.py

index 2c0c3fce395c05011a114b3227e01843f58640f2..e73b174a1fed351c03cf8c22bd791900e4f76cb9 100644 (file)
@@ -36,8 +36,9 @@ class Task_MOVE(Task):
         test_pos = self.get_move_target()
         if test_pos is None:
             raise PlayError('would move out of map')
-        elif test_pos in [t.position for t in self.thing.game.things]:
-            raise PlayError('would collide with other things')
+        elif test_pos in [t.position for t in self.thing.game.things
+                          if t.blocking]:
+            raise PlayError('blocked by other thing')
         elif self.thing.game.map[test_pos] != '.':
             raise PlayError('would move into illegal territory')
 
index ecddc8767483dd8599b43a373de5392127fc260e..d1fc7110b8bba8ca32baeeb1105d69b4c43c880b 100644 (file)
@@ -17,6 +17,7 @@ class ThingBase:
 
 
 class Thing(ThingBase):
+    blocking = False
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
@@ -39,6 +40,7 @@ class Thing_Stone(Thing):
 
 
 class ThingAnimate(Thing):
+    blocking = True
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)