X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;ds=sidebyside;f=new%2Fplomrogue%2Fthings.py;h=8900d9a983d751490b7b0d84f0802d9b2efae1ec;hb=8f4f45798471d5b0069d7ac2caaf7d6a389ce981;hp=f300148a7ad5397c6a3b610d6cd818c1edeef477;hpb=8d7f49fd474eab519468f6ce0d7cf7dd4a69ec60;p=plomrogue2-experiments
diff --git a/new/plomrogue/things.py b/new/plomrogue/things.py
index f300148..8900d9a 100644
--- a/new/plomrogue/things.py
+++ b/new/plomrogue/things.py
@@ -51,7 +51,7 @@ class Thing(ThingBase):
def _position_set(self, pos):
super()._position_set(pos)
for t_id in self.inventory:
- t = self.game.get_thing(t_id)
+ t = self.game.get_thing(t_id, create_unfound=False)
t.position = self.position
if not self.id_ == self.game.player_id:
return
@@ -110,6 +110,19 @@ class ThingAnimate(Thing):
self.set_task('WAIT')
self._last_task_result = None
self.unset_surroundings()
+ self.close_maps = ()
+
+ def _position_set(self, pos):
+ """For player we need to update .close_maps on every move via the
+ self.surroundings property method, to keep their reality
+ bubble in sync with their movement.
+
+ """
+ super()._position_set(pos)
+ if self.id_ == self.game.player_id:
+ if not hasattr(self, '_surroundings'):
+ self._surroundings = None
+ self.surroundings
def move_on_dijkstra_map(self, own_pos, targets):
visible_map = self.get_visible_map()
@@ -174,12 +187,12 @@ class ThingAnimate(Thing):
def hunt_food_satisfaction(self):
for id_ in self.inventory:
- t = self.game.get_thing(id_)
+ t = self.game.get_thing(id_, create_unfound=False)
if t.type_ == 'food':
self.set_task('EAT', (id_,))
return True
for id_ in self.get_pickable_items():
- t = self.game.get_thing(id_)
+ t = self.game.get_thing(id_, create_unfound=False)
if t.type_ == 'food':
self.set_task('PICKUP', (id_,))
return True
@@ -233,6 +246,7 @@ class ThingAnimate(Thing):
if self is self.game.player:
self.game.player_is_alive = False
else:
+ # TODO: Handle inventory.
del self.game.things[self.game.things.index(self)]
return
try:
@@ -270,9 +284,12 @@ class ThingAnimate(Thing):
def surroundings(self):
if self._surroundings is not None:
return self._surroundings
- s = self.game.map_geometry.get_view(self.game.map_size,
- self.game.get_map,
- self._radius, self.view_offset)
+ s, close_maps = self.\
+ game.map_geometry.get_view_and_seen_maps(self.game.map_size,
+ self.game.get_map,
+ self._radius,
+ self.view_offset)
+ self.close_maps = close_maps
self._surroundings = s
return self._surroundings