Browse Source

attack brain part

Bastien Sevajol 9 years ago
parent
commit
33209b24eb
2 changed files with 7 additions and 2 deletions
  1. 2 1
      intelligine/cst.py
  2. 5 1
      intelligine/synergy/event/attack/NearAttackableEvent.py

+ 2 - 1
intelligine/cst.py View File

@@ -40,4 +40,5 @@ COL_TRANSPORTER_NOT_CARRYING = IncrementedNamedInt.get('intelligine.col.transpor
40 40
 BRAIN_SCHEMA = IncrementedNamedInt.get('intelligine.brain_schema')
41 41
 BRAIN_PART_MOVE = IncrementedNamedInt.get('intelligine.brain.part.move')
42 42
 BRAIN_PART_TAKE = IncrementedNamedInt.get('intelligine.brain.part.take')
43
-BRAIN_PART_PUT = IncrementedNamedInt.get('intelligine.brain.part.put')
43
+BRAIN_PART_PUT = IncrementedNamedInt.get('intelligine.brain.part.put')
44
+BRAIN_PART_ATTACK = IncrementedNamedInt.get('intelligine.brain.part.attack')

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

@@ -2,7 +2,7 @@ from intelligine.core.exceptions import NearNothingFound
2 2
 from synergine.core.exceptions import NotConcernedEvent
3 3
 from intelligine.synergy.event.src.NearEvent import NearEvent
4 4
 from xyzworld.mechanism.ArroundMechanism import ArroundMechanism
5
-from intelligine.cst import ATTACKABLE, COLONY, COL_FIGHTER
5
+from intelligine.cst import ATTACKABLE, COLONY, COL_FIGHTER, BRAIN_PART_ATTACK
6 6
 
7 7
 
8 8
 class NearAttackableEvent(NearEvent):
@@ -24,4 +24,8 @@ class NearAttackableEvent(NearEvent):
24 24
         except NearNothingFound:
25 25
             raise NotConcernedEvent()
26 26
 
27
+        brain_part = self._get_brain_part(context, object_id, BRAIN_PART_ATTACK)
28
+        if not brain_part.can_attack(context, object_id, parameters[self._near_name][0]):
29
+            raise NotConcernedEvent()
30
+
27 31
         return parameters