Browse Source

Adapt code to synergine [master 6d63269] SynergyObject now need collection on innit and collection is not passed to Action::run

Bastien Sevajol 9 years ago
parent
commit
eccacb2b8c

+ 1 - 1
intelligine/sandbox/colored/RedColonyConfiguration.py View File

15
         for x in range(50):
15
         for x in range(50):
16
           for y in range(1, 50):
16
           for y in range(1, 50):
17
             if x % 3 == 0 and y % 3 == 0:
17
             if x % 3 == 0 and y % 3 == 0:
18
-              egg = Egg(context)
18
+              egg = Egg(collection, context)
19
               egg.set_position((0, 1+x, 50+y))
19
               egg.set_position((0, 1+x, 50+y))
20
               # TODO: Ce COLONY doit devenir un truc automatise au niveau de la collection (qd get_object)
20
               # TODO: Ce COLONY doit devenir un truc automatise au niveau de la collection (qd get_object)
21
               context.metas.value.set(COLONY, egg.get_id(), collection.get_id())
21
               context.metas.value.set(COLONY, egg.get_id(), collection.get_id())

+ 2 - 2
intelligine/synergy/ColonyConfiguration.py View File

11
     def get_start_objects(self, collection, context):
11
     def get_start_objects(self, collection, context):
12
 
12
 
13
       ants = []
13
       ants = []
14
-      for i in range(20):
15
-          ant = self._ant_class(context)
14
+      for i in range(50):
15
+          ant = self._ant_class(collection, context)
16
           context.metas.value.set(COLONY, ant.get_id(), collection.get_id())
16
           context.metas.value.set(COLONY, ant.get_id(), collection.get_id())
17
           ant.set_position(self._start_position)
17
           ant.set_position(self._start_position)
18
           ants.append(ant)
18
           ants.append(ant)

+ 1 - 1
intelligine/synergy/RocksConfiguration.py View File

29
       rocks_positions.append((0, 100, 100))
29
       rocks_positions.append((0, 100, 100))
30
 
30
 
31
       for rock_position in rocks_positions:
31
       for rock_position in rocks_positions:
32
-          rock = Rock(context)
32
+          rock = Rock(collection, context)
33
           rock.set_position(rock_position)
33
           rock.set_position(rock_position)
34
           rocks.append(rock)
34
           rocks.append(rock)
35
 
35
 

+ 1 - 1
intelligine/synergy/event/CycleAction.py View File

7
 
7
 
8
     _listen = CycleEvent
8
     _listen = CycleEvent
9
 
9
 
10
-    def run(self, obj, collection, context, synergy_manager):
10
+    def run(self, obj, context, synergy_manager):
11
       # TODO: refact ...
11
       # TODO: refact ...
12
       cant_carry_still = context.metas.value.get(CANT_CARRY_STILL, obj.get_id(), allow_empty=True, empty_value=0)
12
       cant_carry_still = context.metas.value.get(CANT_CARRY_STILL, obj.get_id(), allow_empty=True, empty_value=0)
13
       if cant_carry_still > 0:
13
       if cant_carry_still > 0:

+ 1 - 1
intelligine/synergy/event/attack/NearAttackableAction.py View File

15
     def prepare(self, context):
15
     def prepare(self, context):
16
         pass
16
         pass
17
 
17
 
18
-    def run(self, obj, collection, context, synergy_manager):
18
+    def run(self, obj, context, synergy_manager):
19
         # TODO: reprendre ?
19
         # TODO: reprendre ?
20
         for obj_id_attackable in self._parameters['objects_ids_attackable']:
20
         for obj_id_attackable in self._parameters['objects_ids_attackable']:
21
             obj_attackable = synergy_manager.get_map().get_object(obj_id_attackable)
21
             obj_attackable = synergy_manager.get_map().get_object(obj_id_attackable)

+ 1 - 1
intelligine/synergy/event/move/MoveAction.py View File

53
     def _direction_point_is_possible(self, context, direction_point):
53
     def _direction_point_is_possible(self, context, direction_point):
54
         return context.position_is_penetrable(direction_point)
54
         return context.position_is_penetrable(direction_point)
55
 
55
 
56
-    def run(self, obj, collection, context, synergy_manager):
56
+    def run(self, obj, context, synergy_manager):
57
         if self._move_to_point is not None:
57
         if self._move_to_point is not None:
58
             obj.set_position(self._move_to_point)
58
             obj.set_position(self._move_to_point)
59
             context.metas.value.set(PREVIOUS_DIRECTION, self._object_id, self._move_to_direction)
59
             context.metas.value.set(PREVIOUS_DIRECTION, self._object_id, self._move_to_direction)

+ 1 - 1
intelligine/synergy/event/transport/PutableAction.py View File

15
     def prepare(self, context):
15
     def prepare(self, context):
16
         pass
16
         pass
17
 
17
 
18
-    def run(self, obj, collection, context, synergy_manager):
18
+    def run(self, obj, context, synergy_manager):
19
         # TODO: DEV
19
         # TODO: DEV
20
         obj_id_transportable = self._parameters['objects_ids_transportable'][0]
20
         obj_id_transportable = self._parameters['objects_ids_transportable'][0]
21
         obj_transportable = synergy_manager.get_map().get_object(obj_id_transportable)
21
         obj_transportable = synergy_manager.get_map().get_object(obj_id_transportable)

+ 1 - 1
intelligine/synergy/event/transport/TakeableAction.py View File

14
     def prepare(self, context):
14
     def prepare(self, context):
15
         pass
15
         pass
16
 
16
 
17
-    def run(self, obj, collection, context, synergy_manager):
17
+    def run(self, obj, context, synergy_manager):
18
         # TODO: TEST
18
         # TODO: TEST
19
         # TODO: Enlever le state de transportable a ce qui est transporte
19
         # TODO: Enlever le state de transportable a ce qui est transporte
20
         # ?! Comment gerer lorsque deux obj vont vouloir transporter le meme objet ? process !
20
         # ?! Comment gerer lorsque deux obj vont vouloir transporter le meme objet ? process !

+ 2 - 2
intelligine/synergy/object/BaseBug.py View File

4
 
4
 
5
 class BaseBug(XyzSynergyObject):
5
 class BaseBug(XyzSynergyObject):
6
 
6
 
7
-    def __init__(self, context):
8
-        super().__init__(context)
7
+    def __init__(self, collection, context):
8
+        super().__init__(collection, context)
9
         context.metas.states.add_list(self.get_id(), [ALIVE, ATTACKABLE])
9
         context.metas.states.add_list(self.get_id(), [ALIVE, ATTACKABLE])
10
         context.metas.collections.add(self.get_id(), COL_ALIVE)
10
         context.metas.collections.add(self.get_id(), COL_ALIVE)
11
         self._life_points = 10
11
         self._life_points = 10

+ 2 - 2
intelligine/synergy/object/Bug.py View File

4
 
4
 
5
 class Bug(BaseBug):
5
 class Bug(BaseBug):
6
 
6
 
7
-    def __init__(self, context):
8
-        super().__init__(context)
7
+    def __init__(self, collection, context):
8
+        super().__init__(collection, context)
9
         context.metas.states.add(self.get_id(), WALKER)
9
         context.metas.states.add(self.get_id(), WALKER)
10
         context.metas.collections.add(self.get_id(), COL_WALKER)
10
         context.metas.collections.add(self.get_id(), COL_WALKER)

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

4
 
4
 
5
 class Egg(BaseBug):
5
 class Egg(BaseBug):
6
 
6
 
7
-    def __init__(self, context):
8
-        super().__init__(context)
7
+    def __init__(self, collection, context):
8
+        super().__init__(collection, context)
9
         context.metas.states.add(self.get_id(), TRANSPORTABLE)
9
         context.metas.states.add(self.get_id(), TRANSPORTABLE)
10
         self._life_points = 1
10
         self._life_points = 1

+ 2 - 2
intelligine/synergy/object/Rock.py View File

4
 
4
 
5
 class Rock(XyzSynergyObject):
5
 class Rock(XyzSynergyObject):
6
 
6
 
7
-    def __init__(self, context):
8
-        super().__init__(context)
7
+    def __init__(self, collection, context):
8
+        super().__init__(collection, context)
9
         context.metas.states.add(self.get_id(), IMPENETRABLE)
9
         context.metas.states.add(self.get_id(), IMPENETRABLE)

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

5
 
5
 
6
 class Ant(Bug):
6
 class Ant(Bug):
7
 
7
 
8
-    def __init__(self, context):
9
-        super().__init__(context)
8
+    def __init__(self, collection, context):
9
+        super().__init__(collection, context)
10
         context.metas.states.add_list(self.get_id(), [TRANSPORTER, ATTACKER])
10
         context.metas.states.add_list(self.get_id(), [TRANSPORTER, ATTACKER])
11
         context.metas.collections.add_list(self.get_id(), [COL_TRANSPORTER_NOT_CARRYING, COL_FIGHTER])
11
         context.metas.collections.add_list(self.get_id(), [COL_TRANSPORTER_NOT_CARRYING, COL_FIGHTER])
12
         self._carried = []
12
         self._carried = []