def attack(cell): global hero if hero.components['Health'].is_alive(): for obj in cell.objects: if can_attack(hero, obj): return
def execute(self, actor): enemies = actor.components['Perception'].get_enemies() #print 'Attack: ', actor.name, ' ', len(enemies) if len(enemies) is 0: return 'Failed' enemy = enemies[0] if can_attack(actor, enemy): #actor.attack(enemy) return 'Success' path = actor.find_path(enemy.body.x, enemy.body.y) if path is not None and path.has_next(): if can_move(actor, path.get()): path.next() return 'Success' return 'Failed'