Bastien Sevajol 9 years ago
parent
commit
55cefd1ee6

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

4
 
4
 
5
 class CycleEvent(Event):
5
 class CycleEvent(Event):
6
 
6
 
7
-    concern = COL_TRANSPORTER
7
+    _concern = COL_TRANSPORTER
8
 
8
 
9
     def _prepare(self, object_id, context, parameters):
9
     def _prepare(self, object_id, context, parameters):
10
         return parameters
10
         return parameters

+ 3 - 6
intelligine/synergy/event/attack/NearAttackableEvent.py View File

1
 from intelligine.core.exceptions import NearNothingFound
1
 from intelligine.core.exceptions import NearNothingFound
2
 from synergine.core.exceptions import NotConcernedEvent
2
 from synergine.core.exceptions import NotConcernedEvent
3
 from intelligine.synergy.event.src.NearEvent import NearEvent
3
 from intelligine.synergy.event.src.NearEvent import NearEvent
4
-from xyzworld.mechanism.ArroundMechanism import ArroundMechanism
4
+from xyzworld.mechanism.AroundMechanism import AroundMechanism
5
 from intelligine.cst import ATTACKABLE, COLONY, COL_FIGHTER, BRAIN_PART_ATTACK
5
 from intelligine.cst import ATTACKABLE, COLONY, COL_FIGHTER, BRAIN_PART_ATTACK
6
 
6
 
7
 
7
 
8
 class NearAttackableEvent(NearEvent):
8
 class NearAttackableEvent(NearEvent):
9
 
9
 
10
-    concern = COL_FIGHTER
10
+    _mechanism = AroundMechanism
11
+    _concern = COL_FIGHTER
11
     _near_name = 'objects_ids_attackable'
12
     _near_name = 'objects_ids_attackable'
12
     _near_map = lambda self, near_object_id, context: context.metas.states.have(near_object_id, ATTACKABLE)
13
     _near_map = lambda self, near_object_id, context: context.metas.states.have(near_object_id, ATTACKABLE)
13
 
14
 
14
-    def __init__(self, actions):
15
-        super().__init__(actions)
16
-        self._mechanism = ArroundMechanism
17
-
18
     def _prepare(self, object_id, context, parameters={}):
15
     def _prepare(self, object_id, context, parameters={}):
19
         obj_colony_id = context.metas.value.get(COLONY, object_id)
16
         obj_colony_id = context.metas.value.get(COLONY, object_id)
20
         filter = lambda near_object_id, context: obj_colony_id != context.metas.value.get(COLONY, near_object_id)
17
         filter = lambda near_object_id, context: obj_colony_id != context.metas.value.get(COLONY, near_object_id)

+ 2 - 5
intelligine/synergy/event/move/MoveEvent.py View File

12
     PARAM_POSITION = 'pos'
12
     PARAM_POSITION = 'pos'
13
     PARAM_DIRECTION = 'dir'
13
     PARAM_DIRECTION = 'dir'
14
 
14
 
15
-    concern = COL_WALKER
16
-
17
-    def __init__(self, actions):
18
-        super().__init__(actions)
19
-        self._mechanism = Mechanism
15
+    _mechanism = Mechanism
16
+    _concern = COL_WALKER
20
 
17
 
21
     def _prepare(self, object_id, context, parameters={}):
18
     def _prepare(self, object_id, context, parameters={}):
22
         try:
19
         try:

+ 2 - 5
intelligine/synergy/event/src/NearEvent.py View File

1
 from intelligine.core.exceptions import NearNothingFound
1
 from intelligine.core.exceptions import NearNothingFound
2
 from intelligine.synergy.event.Event import Event
2
 from intelligine.synergy.event.Event import Event
3
-from xyzworld.mechanism.ArroundMechanism import ArroundMechanism
3
+from xyzworld.mechanism.AroundMechanism import AroundMechanism
4
 
4
 
5
 
5
 
6
 class NearEvent(Event):
6
 class NearEvent(Event):
7
 
7
 
8
+    _mechanism = AroundMechanism
8
     _near_name = None
9
     _near_name = None
9
     _near_map = lambda self, near_object_id, context: False
10
     _near_map = lambda self, near_object_id, context: False
10
 
11
 
11
-    def __init__(self, actions):
12
-        super().__init__(actions)
13
-        self._mechanism = ArroundMechanism
14
-
15
     # TODO: parameters en entre/sortie c pas bon ca
12
     # TODO: parameters en entre/sortie c pas bon ca
16
     def map(self, context, parameters, stop_at_first=False, filter=lambda near_object_id, context: True):
13
     def map(self, context, parameters, stop_at_first=False, filter=lambda near_object_id, context: True):
17
         for near_object_id in parameters['objects_ids_near']:
14
         for near_object_id in parameters['objects_ids_near']:

+ 3 - 6
intelligine/synergy/event/transport/PutableEvent.py View File

2
 from intelligine.synergy.event.src.NearEvent import NearEvent
2
 from intelligine.synergy.event.src.NearEvent import NearEvent
3
 from synergine.core.exceptions import NotConcernedEvent
3
 from synergine.core.exceptions import NotConcernedEvent
4
 from intelligine.cst import CANT_PUT_STILL, COL_TRANSPORTER_CARRYING, TRANSPORTABLE, BRAIN_SCHEMA, BRAIN_PART_PUT
4
 from intelligine.cst import CANT_PUT_STILL, COL_TRANSPORTER_CARRYING, TRANSPORTABLE, BRAIN_SCHEMA, BRAIN_PART_PUT
5
-from xyzworld.mechanism.ArroundMechanism import ArroundMechanism
5
+from xyzworld.mechanism.AroundMechanism import AroundMechanism
6
 
6
 
7
 
7
 
8
 class PutableEvent(NearEvent):
8
 class PutableEvent(NearEvent):
12
 
12
 
13
     PARAM_PUT = 'put'
13
     PARAM_PUT = 'put'
14
     PARAM_PUT_TO = 'put_to'
14
     PARAM_PUT_TO = 'put_to'
15
-    concern = COL_TRANSPORTER_CARRYING
15
+    _mechanism = AroundMechanism
16
+    _concern = COL_TRANSPORTER_CARRYING
16
     _near_name = 'objects_ids_putable'
17
     _near_name = 'objects_ids_putable'
17
     _near_map = lambda self, near_object_id, context: context.metas.states.have(near_object_id, TRANSPORTABLE)
18
     _near_map = lambda self, near_object_id, context: context.metas.states.have(near_object_id, TRANSPORTABLE)
18
 
19
 
19
-    def __init__(self, actions):
20
-        super().__init__(actions)
21
-        self._mechanism = ArroundMechanism
22
-
23
     def _prepare(self, object_id, context, parameters={}):
20
     def _prepare(self, object_id, context, parameters={}):
24
         if not self._can_put(object_id, context):
21
         if not self._can_put(object_id, context):
25
             raise NotConcernedEvent()
22
             raise NotConcernedEvent()

+ 3 - 6
intelligine/synergy/event/transport/TakeableEvent.py View File

1
 from intelligine.core.exceptions import NearNothingFound
1
 from intelligine.core.exceptions import NearNothingFound
2
 from synergine.core.exceptions import NotConcernedEvent
2
 from synergine.core.exceptions import NotConcernedEvent
3
 from intelligine.synergy.event.src.NearEvent import NearEvent
3
 from intelligine.synergy.event.src.NearEvent import NearEvent
4
-from xyzworld.mechanism.ArroundMechanism import ArroundMechanism
4
+from xyzworld.mechanism.AroundMechanism import AroundMechanism
5
 from intelligine.cst import TRANSPORTABLE, CANT_CARRY_STILL, COL_TRANSPORTER_NOT_CARRYING, BRAIN_SCHEMA, BRAIN_PART_TAKE
5
 from intelligine.cst import TRANSPORTABLE, CANT_CARRY_STILL, COL_TRANSPORTER_NOT_CARRYING, BRAIN_SCHEMA, BRAIN_PART_TAKE
6
 
6
 
7
 
7
 
8
 class TakeableEvent(NearEvent):
8
 class TakeableEvent(NearEvent):
9
 
9
 
10
+    _mechanism = AroundMechanism
10
     PARAM_TAKE = 'take'
11
     PARAM_TAKE = 'take'
11
-    concern = COL_TRANSPORTER_NOT_CARRYING
12
+    _concern = COL_TRANSPORTER_NOT_CARRYING
12
     _near_name = 'objects_ids_transportable'
13
     _near_name = 'objects_ids_transportable'
13
     _near_map = lambda self, near_object_id, context: context.metas.states.have(near_object_id, TRANSPORTABLE)
14
     _near_map = lambda self, near_object_id, context: context.metas.states.have(near_object_id, TRANSPORTABLE)
14
 
15
 
15
-    def __init__(self, actions):
16
-        super().__init__(actions)
17
-        self._mechanism = ArroundMechanism
18
-
19
     def _prepare(self, object_id, context, parameters={}):
16
     def _prepare(self, object_id, context, parameters={}):
20
         if not self._can_carry(object_id, context):
17
         if not self._can_carry(object_id, context):
21
             raise NotConcernedEvent()
18
             raise NotConcernedEvent()