X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=new%2Fplomrogue%2Fthings.py;h=20ce4867c2211882b506de309d8881eb16842379;hb=787d769e0c0f2d2fc50800b60b4bcfd506bedba2;hp=5ef429754c41373dbf9a9b986de63ef88e684303;hpb=599f48bd1d9270cf154e885cf276adb05727507a;p=plomrogue2-experiments diff --git a/new/plomrogue/things.py b/new/plomrogue/things.py index 5ef4297..20ce486 100644 --- a/new/plomrogue/things.py +++ b/new/plomrogue/things.py @@ -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):