Beispiel #1
0
 def get_message(self, locale):
     return locale.translate(spell_messages[19]).format(
         self.who_character.name,
         locale.translate(self.spell_info.name),
         self.whom_character.name,
         self.damage,
         smarty.apply_hp_colour(self.whom_character.health, self.whom_character.full_health),
         self.damage,
         smarty.apply_hp_colour(self.who_character.health, self.who_character.full_health),
         self.experience,
         self.who_character.experience)
Beispiel #2
0
 def get_after_attack_message(self, locale):
     return locale.translate(spell_messages[22]).format(
         self.attack_character.name,
         self.damage,
         smarty.apply_hp_colour(self.attack_character.health, self.attack_character.full_health),
         self.who_character.name,
         self.experience,
         self.who_character.experience)
Beispiel #3
0
 def process_attack_defence_actions(self, attack_actions, defence_actions):
     for action in attack_actions: # attack
         if not self.process_affect_attack_spells(action): # spells didn't help, calculate hit
             defenders = list() # character : action percent
             for def_action in defence_actions: # defence
                 if def_action.whom == action.whom:
                     defenders.append((self.battle_users[def_action.who].battle_character, def_action.percent))
             who_character = self.battle_users[action.who].battle_character
             whom_character = self.battle_users[action.whom].battle_character
             if smarty.is_hit(who_character, action.percent, defenders):
                 damage = smarty.get_damage(who_character, action.percent, whom_character)
                 if smarty.is_critical_hit(who_character, whom_character):
                     self.send_text_action_to_users(8, action.who) # critical hit
                     damage *= 1.5
                 whom_character.health -= damage
                 experience = 0
                 if who_character.name != whom_character.name:
                     experience = smarty.get_experience_for_damage(damage)
                     self.add_experience(who_character.name, experience)
                     if whom_character.health <= 0 and not whom_character.killer_name:
                         whom_character.killer_name = action.who
                 self.succeeded_attack(
                     action.who,
                     action.whom,
                     damage,
                     smarty.apply_hp_colour(whom_character.health, whom_character.full_health),
                     experience,
                     who_character.experience)
                 self.process_after_attack_spells(action, damage)
             else: # not hit - set exp to defenders
                 damage = smarty.get_damage(who_character, action.percent, whom_character)
                 if smarty.is_critical_hit(who_character, whom_character):
                     damage *= 1.5
                 all_defence = 0
                 for defender in defenders:
                     if who_character.name != defender[0].name:
                         all_defence += defender[0].defence
                 all_experience = smarty.get_experience_for_defence(damage)
                 defence_experience = list()
                 for def_action in defence_actions: # defence
                     if def_action.whom == action.whom:
                         def_experience = 0
                         def_character = self.battle_users[def_action.who].battle_character
                         if def_action.who != action.who:
                             def_experience = round(all_experience*(def_character.defence/all_defence))
                             self.add_experience(def_character.name, def_experience)
                         defence_experience.append("<b>{0}</b>[<font class=\"font-exp\">{1}</font>/<font class=\"font-exp\">{2}</font>]".format(def_action.who, def_experience, def_character.experience))
                 self.failed_attack(action.who, action.whom, ",".join(defence_experience))