NearAttackableAction.py 943B

12345678910111213141516171819202122232425
  1. from synergine.synergy.event.Action import Action
  2. from intelligine.synergy.event.attack.NearAttackableEvent import NearAttackableEvent
  3. from random import randint
  4. from intelligine.cst import ALIVE, ATTACKABLE, ACTION_DIE
  5. from synergine.core.Signals import Signals
  6. class NearAttackableAction(Action):
  7. _listen = NearAttackableEvent
  8. def __init__(self, object_id, parameters):
  9. super().__init__(object_id, parameters)
  10. def prepare(self, context):
  11. pass
  12. def run(self, obj, context, synergy_manager):
  13. # TODO: reprendre ?
  14. for obj_id_attackable in self._parameters['objects_ids_attackable']:
  15. obj_attackable = synergy_manager.get_map().get_object(obj_id_attackable)
  16. obj_attackable.hurted(randint(0, 2))
  17. if obj_attackable.get_life_points() <= 0:
  18. obj_attackable.die()
  19. Signals.signal(ACTION_DIE).send(obj=obj_attackable, context=context)