Browse Source

dev on egg smell

Bastien Sevajol 9 years ago
parent
commit
96241d7f8f

+ 13 - 0
intelligine/display/Pygame.py View File

59
                 pass # No molecule here
59
                 pass # No molecule here
60
 
60
 
61
             try:
61
             try:
62
+                molecule = point_flavour.get_molecule(category=MOLECULES_DIRECTION, type=SMELL_EGG)
63
+                self.draw_surface(point, smell_food_surface)
64
+
65
+                adapted_point = self._get_real_pixel_position_of_position(point)
66
+                adapted_point = (adapted_point[0]+10, adapted_point[1]+10)
67
+                myfont = pygame.font.SysFont("monospace", 15)
68
+                label = myfont.render(str(molecule.get_distance()), 1, (255,255,0))
69
+                self._screen.blit(label, adapted_point)
70
+
71
+            except NoMolecule:
72
+                pass # No molecule here
73
+
74
+            try:
62
                 point_flavour.get_molecule(category=MOLECULES_DIRECTION, type=SMELL_EGG)
75
                 point_flavour.get_molecule(category=MOLECULES_DIRECTION, type=SMELL_EGG)
63
                 self.draw_surface(point, smell_egg_surface)
76
                 self.draw_surface(point, smell_egg_surface)
64
             except NoMolecule:
77
             except NoMolecule:

+ 2 - 1
intelligine/simulation/object/brain/part/transport/AntPutBrainPart.py View File

16
     })
16
     })
17
 
17
 
18
     _types_matches = {
18
     _types_matches = {
19
-        TYPE_RESOURCE_EXPLOITABLE: [TYPE_RESOURCE_EATABLE]
19
+        TYPE_RESOURCE_EXPLOITABLE: [TYPE_RESOURCE_EATABLE],
20
+        TYPE_NURSERY: [TYPE_NURSERY]
20
     }
21
     }
21
 
22
 
22
     @classmethod
23
     @classmethod

+ 7 - 2
intelligine/synergy/event/smell/SmellAction.py View File

1
+from intelligine.core.exceptions import BestMoleculeHere
1
 from intelligine.cst import POINT_SMELL, POINTS_SMELL, MOLECULES_INFOS, MOLECULES_DIRECTION, SMELL_FOOD, SMELL_EGG
2
 from intelligine.cst import POINT_SMELL, POINTS_SMELL, MOLECULES_INFOS, MOLECULES_DIRECTION, SMELL_FOOD, SMELL_EGG
2
 from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
3
 from intelligine.simulation.molecule.DirectionMolecule import DirectionMolecule
3
 from intelligine.simulation.molecule.Molecule import Molecule
4
 from intelligine.simulation.molecule.Molecule import Molecule
23
         context.metas.list.unset(POINTS_SMELL, POINTS_SMELL, allow_empty=True)
24
         context.metas.list.unset(POINTS_SMELL, POINTS_SMELL, allow_empty=True)
24
 
25
 
25
     def run(self, obj, context, synergy_manager):
26
     def run(self, obj, context, synergy_manager):
26
-        # TODO: Utiliser molecule
27
+
27
         points_distances = self._parameters['points_distances']
28
         points_distances = self._parameters['points_distances']
28
         smell_type = obj.get_smell()
29
         smell_type = obj.get_smell()
29
 
30
 
30
         for smell_point in points_distances:
31
         for smell_point in points_distances:
31
             distance = points_distances[smell_point]
32
             distance = points_distances[smell_point]
32
             molecule = Molecule(MOLECULES_DIRECTION, smell_type, distance)
33
             molecule = Molecule(MOLECULES_DIRECTION, smell_type, distance)
33
-            DirectionMolecule.appose(context, smell_point, molecule)
34
+
35
+            try:
36
+                DirectionMolecule.appose(context, smell_point, molecule)
37
+            except BestMoleculeHere:
38
+                pass  #
34
 
39
 
35
             #
40
             #
36
             # current_point_smell = points_distances[smell_point]
41
             # current_point_smell = points_distances[smell_point]

+ 2 - 1
intelligine/synergy/object/Egg.py View File

1
 from intelligine.synergy.object.BaseBug import BaseBug
1
 from intelligine.synergy.object.BaseBug import BaseBug
2
-from intelligine.cst import TYPE_NURSERY, TYPE, SMELL_EGG
2
+from intelligine.cst import TYPE_NURSERY, TYPE, SMELL_EGG, COL_SMELL
3
 
3
 
4
 
4
 
5
 class Egg(BaseBug):
5
 class Egg(BaseBug):
8
         super().__init__(collection, context)
8
         super().__init__(collection, context)
9
         context.metas.list.add(TYPE, self.get_id(), TYPE_NURSERY)
9
         context.metas.list.add(TYPE, self.get_id(), TYPE_NURSERY)
10
         self._life_points = 1
10
         self._life_points = 1
11
+        self._add_col(COL_SMELL)
11
         self._set_smell(SMELL_EGG)
12
         self._set_smell(SMELL_EGG)