def applic_action(self): self.applic_ok = True color_heal = (0,255,0,255) color_hit = (255,0,0,255) color_mp = (0,255,0,255) power = 0 modif = 1. rnd = 1. if self.action not in ('fight-enemy','fight-hero') and self.action not in ITEMS: power = LEVELS[self.heros[self.active].level][self.action] name = self.target.name if self.action not in FRIEND_SKILL: modif = MONSTERS[name][self.action] if self.action in ITEMS: power = ITEMS[self.action] if self.action == 'stone': power += LEVELS[self.heros[self.active].level]['hit'] if self.action == 'fight-hero': power = LEVELS[self.heros[self.active].level]['hit'] if self.action == 'fight-enemy': name = self.origin.name power = MONSTERS[name]['hit'] #modification de la puissance if self.action not in ITEMS: rnd = random.randint(5,15) * 0.1 power = int(power * rnd * modif) #effet if self.action in FRIEND_SKILL: if self.action == 'honey': self.target.mp[0] += power if self.target.mp[0] > self.target.mp[1]: self.target.mp[0] = self.target.mp[1] else: ok = True if self.action in ('life','dragon blood'): if not self.target.is_dead(): ok = False if self.action in ('potion','heal'): if self.target.is_dead(): ok = False if not ok: power = 0 self.target.hp += power else: self.target.hp -= power if self.action in MAGIC: self.origin.mp[0] -= MAGIC[self.action] elif self.action in ITEMS: INVENTORY.remove(self.action) #position pos = self.target.position pos = pos[0], pos[1] + self.target.height - 20 #couleur du texte if self.action in FRIEND_SKILL: if self.action == 'honey': color = color_mp else: color = color_heal else: color = color_hit label = cocos.text.Label(text = str(power),position = pos, font_name = 'Statix', color= color , font_size = 30, anchor_x = 'center') to = pos[0], pos[1] + 30 action = cocos.actions.interval_actions.MoveTo(to, 0.5) label.do(action) self.add(label) self.attacks.append(label)