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
         context.metas.collections.add_list(self.get_id(), [COL_TRANSPORTER,
17
         context.metas.collections.add_list(self.get_id(), [COL_TRANSPORTER,
18
                                                            COL_TRANSPORTER_NOT_CARRYING,
18
                                                            COL_TRANSPORTER_NOT_CARRYING,
19
                                                            COL_FIGHTER])
19
                                                            COL_FIGHTER])
20
-        self._carried = []
20
+        self._carried = None
21
         # TODO: Faire un body_part schema pour ces trucs la
21
         # TODO: Faire un body_part schema pour ces trucs la
22
         self._movement_pheromone_gland = MovementPheromoneGland(self, self._context)
22
         self._movement_pheromone_gland = MovementPheromoneGland(self, self._context)
23
         self._brain.switch_to_mode(MOVE_MODE_EXPLO)
23
         self._brain.switch_to_mode(MOVE_MODE_EXPLO)
31
     def put_carry(self, obj, position=None):
31
     def put_carry(self, obj, position=None):
32
         if position is None:
32
         if position is None:
33
             position = self._get_position()
33
             position = self._get_position()
34
-        self._carried.remove(obj)
34
+        self._carried = None
35
         obj.set_position(position)
35
         obj.set_position(position)
36
         self._context.metas.states.remove(self.get_id(), CARRYING)
36
         self._context.metas.states.remove(self.get_id(), CARRYING)
37
 
37
 
38
     def get_carried(self):
38
     def get_carried(self):
39
-        # TODO: cas ou plusieurs ?
40
-        return self._carried[0]
39
+        return self._carried
41
 
40
 
42
     def carry(self, obj):
41
     def carry(self, obj):
43
-        self._carried.append(obj)
42
+        self._carried = obj
44
         self._context.metas.states.add(self.get_id(), CARRYING)
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
         self._context.metas.value.set(CARRIED, self.get_id(), obj.get_id())
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
         if isinstance(obj, Food):
46
         if isinstance(obj, Food):
49
             self.get_brain().switch_to_mode(MOVE_MODE_GOHOME)
47
             self.get_brain().switch_to_mode(MOVE_MODE_GOHOME)
50
             self.get_movement_pheromone_gland().appose()
48
             self.get_movement_pheromone_gland().appose()
51
 
49
 
52
     def is_carrying(self):
50
     def is_carrying(self):
53
-        if len(self._carried):
51
+        if self._carried:
54
             return True
52
             return True
55
         return False
53
         return False
56
 
54
 
57
-    # TODO: Est-ce ici que doit etre ce code ?
58
     def set_position(self, position):
55
     def set_position(self, position):
59
         if self._position is not None and position != self._position:
56
         if self._position is not None and position != self._position:
60
             self._brain.host_moved()
57
             self._brain.host_moved()
61
         super().set_position(position)
58
         super().set_position(position)
62
         if self.is_carrying():
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
     def initialize(self):
62
     def initialize(self):
67
         super().initialize()
63
         super().initialize()