Browse Source

ant._carried is not a list anymore

Bastien Sevajol 9 years ago
parent
commit
b34421eb5e
1 changed files with 7 additions and 11 deletions
  1. 7 11
      intelligine/synergy/object/ant/Ant.py

+ 7 - 11
intelligine/synergy/object/ant/Ant.py View File

@@ -17,7 +17,7 @@ class Ant(Bug):
17 17
         context.metas.collections.add_list(self.get_id(), [COL_TRANSPORTER,
18 18
                                                            COL_TRANSPORTER_NOT_CARRYING,
19 19
                                                            COL_FIGHTER])
20
-        self._carried = []
20
+        self._carried = None
21 21
         # TODO: Faire un body_part schema pour ces trucs la
22 22
         self._movement_pheromone_gland = MovementPheromoneGland(self, self._context)
23 23
         self._brain.switch_to_mode(MOVE_MODE_EXPLO)
@@ -31,37 +31,33 @@ class Ant(Bug):
31 31
     def put_carry(self, obj, position=None):
32 32
         if position is None:
33 33
             position = self._get_position()
34
-        self._carried.remove(obj)
34
+        self._carried = None
35 35
         obj.set_position(position)
36 36
         self._context.metas.states.remove(self.get_id(), CARRYING)
37 37
 
38 38
     def get_carried(self):
39
-        # TODO: cas ou plusieurs ?
40
-        return self._carried[0]
39
+        return self._carried
41 40
 
42 41
     def carry(self, obj):
43
-        self._carried.append(obj)
42
+        self._carried = obj
44 43
         self._context.metas.states.add(self.get_id(), CARRYING)
45
-        #  TODO: On gere une liste de carried (mais pas juste la dessous). Ne gerer qu'un objet carried ?
46 44
         self._context.metas.value.set(CARRIED, self.get_id(), obj.get_id())
47
-        # TODO: pour le moment hardcode
45
+        # TODO: pour le moment hardcode, a gerer dans AntTakeBrainPart (callback en fct de ce qui est depose)
48 46
         if isinstance(obj, Food):
49 47
             self.get_brain().switch_to_mode(MOVE_MODE_GOHOME)
50 48
             self.get_movement_pheromone_gland().appose()
51 49
 
52 50
     def is_carrying(self):
53
-        if len(self._carried):
51
+        if self._carried:
54 52
             return True
55 53
         return False
56 54
 
57
-    # TODO: Est-ce ici que doit etre ce code ?
58 55
     def set_position(self, position):
59 56
         if self._position is not None and position != self._position:
60 57
             self._brain.host_moved()
61 58
         super().set_position(position)
62 59
         if self.is_carrying():
63
-            for obj_carried in self._carried:
64
-                obj_carried.set_position(position)
60
+            self._carried.set_position(position)
65 61
 
66 62
     def initialize(self):
67 63
         super().initialize()