NearAttackableEvent.py 1022B

1234567891011121314151617181920212223242526
  1. from synergine.synergy.event.Event import Event
  2. from xyzworld.mechanism.ArroundMechanism import ArroundMechanism
  3. from intelligine.cst import ATTACKABLE, COLONY, COL_FIGHTER
  4. class NearAttackableEvent(Event):
  5. concern = COL_FIGHTER
  6. def __init__(self, actions):
  7. super().__init__(actions)
  8. self._mechanism = ArroundMechanism
  9. def _object_match(self, object_id, context, parameters={}):
  10. # TODO: nettoyer
  11. obj_colony_id = context.metas.value.get(COLONY, object_id)
  12. for obj_near_id in parameters['objects_ids_near']:
  13. if context.metas.states.have(obj_near_id, ATTACKABLE):
  14. if obj_colony_id != context.metas.value.get(COLONY, obj_near_id):
  15. if 'objects_ids_attackable' not in parameters:
  16. parameters['objects_ids_attackable'] = []
  17. parameters['objects_ids_attackable'].append(obj_near_id)
  18. if 'objects_ids_attackable' not in parameters:
  19. return False
  20. return True