Ejemplo n.º 1
0
    def _hit(self, caster, target):
        defense_roll = GameRules.roll_saving_spell_throw(self, target)
        attack_roll = GameRules.roll_spell_attack_score(self, caster)
        caster.notify_observers_log("{} - cast {}".format(caster.class_name, self.class_name))
        caster.notify_observers_log('Defense: {}({}), Attack: {}({})'.format(defense_roll.total,defense_roll.roll,attack_roll.total,attack_roll.roll))

        hit = defense_roll.roll < 20 and attack_roll.total >= defense_roll.total
        if not hit:
            caster.notify_observers_log("{} - {} missed {}".format(caster.class_name, self.class_name, target.class_name))
            caster.notify_observers_reply(ReplyHelpers.render_action_template(caster.get_reply_key('cast_miss'), spell_text=self.description,
                attacker_name=caster.name, defender_name=target.name, mana_points=caster.mana_points))
        return hit
Ejemplo n.º 2
0
 def _hit(self, caster, target):
     #If casting on one self it always hits
     if caster == target: return True
     defense_target = self.spell_difficulty_class(caster)
     saving_roll = GameRules.roll_saving_spell_throw(self, target)
     from questgame.players.players import Player
     if isinstance(target, Player):
         save = saving_roll.total
         caster.notify_observers_log('Defense: {}, Saving: {}({})'.format(defense_target, saving_roll.total, saving_roll.roll))
     else:
         save = target.spell_resistance
         caster.notify_observers_log('Defense: {}, Saving: {}'.format(defense_target, save))
     hit = save < 20 and save <= defense_target
     if not hit:
         caster.notify_observers_log('{} failed on {}'.format(self.__class__.__name__,target.__class__.__name__))
     return hit