Пример #1
0
    def check_skill(self, entity, skill, modifier=0):
        skill_level = self.get_skill_level(entity, skill_tree[skill])
        skill_level += modifier

        roll = random.roll_dice(3)

        success = roll <= skill_level or roll <= 4
        critical = roll <= 6 and roll*3 <= skill_level
        dos = skill_level - roll

        if success and critical:
            dos += random.roll_dice()
            # Degree of Success on a critical is always at least 1
            dos = max(dos, 1)
        elif success:
            # Degree of Success is always at least 0 for a success
            dos = max(dos, 0)

        return SkillCheckEvent.Result(success, critical, roll, dos)