Exemplo n.º 1
0
 def apply(self, owner, attack):
     try:
         validate_weapon(self, owner)
         validate_delivery(self, attack.delivery)
         validate_dam_type(self, attack.damage_type)
     except ActionError:
         return
     adj_accuracy = roll_calc(owner, self.avoid_calc, self.skill_level)
     combat_log(attack.source, lambda: ''.join(['{N} defense: ', self.name, ' adj_accuracy: ', str(adj_accuracy)]),
                self)
     attack.adj_accuracy -= adj_accuracy
     if attack.adj_accuracy < 0:
         return
     absorb = roll_calc(owner, self.absorb_calc, self.skill_level)
     combat_log(attack.source, lambda: ''.join(['{N} defense: ', self.name, ' absorb: ', str(absorb)]), self)
     attack.adj_damage -= absorb
Exemplo n.º 2
0
 def attacked(self, source, attack):
     for defense in self.defenses:
         defense.apply(self, attack)
         if attack.adj_damage <= 0 or attack.adj_accuracy <= 0:
             if defense.success_map:
                 self.broadcast(target=source, **defense.success_map)
             else:
                 source.broadcast(verb=attack.verb, target=self, **attack.fail_map)
             return
     source.broadcast(verb=attack.verb, target=self, **attack.success_map)
     current_pool = getattr(self, attack.damage_pool)
     setattr(self, attack.damage_pool, current_pool - attack.adj_damage)
     combat_log(source,
                lambda: ''.join(['{N} result -- ', attack.damage_pool, ' old: ',
                                 str(current_pool), ' new: ', str(current_pool - attack.adj_damage)]),
                self)
Exemplo n.º 3
0
 def invoke(self, source, target_method, **_):
     attack = Attack().from_skill(self, source)
     combat_log(source, attack)
     target_method(source, attack)
Exemplo n.º 4
0
 def invoke(self, source, target):
     attack = Attack().from_skill(self, source)
     combat_log(source, attack)
     target.attacked(source, attack)