X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;ds=sidebyside;f=new%2Fplomrogue%2Fthings.py;h=20ce4867c2211882b506de309d8881eb16842379;hb=4cfda20ebdf25c76d28530459126c6e4ecd85248;hp=243547b2ffb854b330fcb998a27882d8ecda2ef9;hpb=c7ed14237418f807473b11e49f17a878ff344f97;p=plomrogue2-experiments
diff --git a/new/plomrogue/things.py b/new/plomrogue/things.py
index 243547b..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:
@@ -17,6 +17,11 @@ class ThingBase:
class Thing(ThingBase):
blocking = False
+ in_inventory = False
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.inventory = []
def proceed(self):
pass
@@ -58,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]
@@ -140,10 +145,20 @@ class ThingAnimate(Thing):
stencil = self.get_stencil()
visible_things = []
for thing in self.world.things:
- if stencil[thing.position] == '.':
+ if (not thing.in_inventory) and stencil[thing.position] == '.':
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):