<commit_before>from roglick.engine.ecs import System, exceptions
from roglick.components import SkillComponent,SkillSubComponent
from roglick.engine import event,random
from roglick.events import SkillCheckEvent
from roglick.skills import skill_tree


class SkillSystem(System):
    @event.event_handler(SkillCheckEvent)
    def skill_check_handler(self, checkevent):
        checkevent.result = self.check_skill(
                checkevent.entity, checkevent.skill, checkevent.modifier)

    def check_skill(self, entity, skill, modifier=0):
        skill_level = self.get_skill_level(entity, skill_tree[skill])
        skill_level += modifier

        roll = 100
        for n in range(3):
            roll = min(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 critical:
            dos += random.roll_dice()

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

    def get_skill_level(self, entity, skill):
        if skill is None:
            return 0

        parent_level = self.get_skill_level(entity, skill.parent)

        return self.get_skill(entity, skill.key).ranks + parent_level/2
<commit_msg>Scrub the "lowest of 3 rolls" on skill checks<commit_after>from roglick.engine.ecs import System, exceptions
from roglick.components import SkillComponent,SkillSubComponent
from roglick.engine import event,random
from roglick.events import SkillCheckEvent
from roglick.skills import skill_tree


class SkillSystem(System):
    @event.event_handler(SkillCheckEvent)
    def skill_check_handler(self, checkevent):
        checkevent.result = self.check_skill(
                checkevent.entity, checkevent.skill, checkevent.modifier)

    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 critical:
            dos += random.roll_dice()

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

    def get_skill_level(self, entity, skill):
        if skill is None:
            return 0

        parent_level = self.get_skill_level(entity, skill.parent)

        return self.get_skill(entity, skill.key).ranks + parent_level/2

{'fraction_non_alphanumeric': 0.08249496981891348, 'fraction_numerical': 0.007645875251509054, 'mean_word_length': 3.095551894563427, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '484646', 'n_tokens_mistral': 755, 'n_tokens_neox': 740, 'n_words': 185}