home · contact · privacy
Minor refactoring.
[plomrogue2-experiments] / new / plomrogue / things.py
index 5ef429754c41373dbf9a9b986de63ef88e684303..20ce4867c2211882b506de309d8881eb16842379 100644 (file)
@@ -5,7 +5,7 @@ from plomrogue.errors import GameError
 class ThingBase:
     type_ = '?'
 
-    def __init__(self, world, id_=None, position=[0,0]):
+    def __init__(self, world, id_=None, position=(0,0)):
         self.world = world
         self.position = position
         if id_ is None:
@@ -63,7 +63,7 @@ class ThingAnimate(Thing):
         neighbors = dijkstra_map.get_neighbors(tuple(self.position))
         n = n_max
         target_direction = None
-        for direction in neighbors:
+        for direction in sorted(neighbors.keys()):
             yx = neighbors[direction]
             if yx is not None:
                 n_new = dijkstra_map[yx]
@@ -149,6 +149,16 @@ class ThingAnimate(Thing):
                 visible_things += [thing]
         return visible_things
 
+    def get_pickable_items(self):
+        pickable_ids = []
+        for t in [t for t in self.get_visible_things() if
+                  isinstance(t, ThingItem) and
+                  (t.position == self.position or
+                   t.position in
+                   self.world.map_.get_neighbors(self.position).values())]:
+            pickable_ids += [t.id_]
+        return pickable_ids
+
 
 
 class ThingHuman(ThingAnimate):