<commit_before>module RpgTools
  class Dice
    attr_accessor :base, :sides, :value, :type, :rolls, :bonus, :malus

    def initialize(base)
      @base  = base
      @value = nil
      @type  = (@base =~ /^.[fF]$/).nil? ? 'Standard' : 'Fudge'
      @sides = @type == 'Fudge' ? 3 : base.gsub(/^./, '').to_i
      @rolls = 0
      check_sides
      set_modifiers if @type == 'Standard'
    end

    def roll
      return fudge_roll      if @type == 'Fudge'
      return standard_roll   if @bonus.nil? && @malus.nil?
      return roll_with_bonus if @malus.nil?
      return roll_with_malus if @bonus.nil?
    end

    private

    def set_modifiers
      @bonus = (@base =~ /[Dd]\d+\+(\d+)/).nil? ? nil : @base.gsub(/[Dd]\d+\+/, '').to_i
      @malus = (@base =~ /[Dd]\d+\-(\d+)/).nil? ? nil : @base.gsub(/[Dd]\d+\-/, '').to_i
    end
<commit_msg>Added argument error raise for wrong dices calls<commit_after>module RpgTools
  class Dice
    attr_accessor :base, :sides, :value, :type, :rolls, :bonus, :malus

    def initialize(base)
      @base  = base
      base_check
      @value = nil
      @type  = (@base =~ /^.[fF]$/).nil? ? 'Standard' : 'Fudge'
      @sides = @type == 'Fudge' ? 3 : base.gsub(/^./, '').to_i
      @rolls = 0
      check_sides
      set_modifiers if @type == 'Standard'
    end

    def roll
      return fudge_roll      if @type == 'Fudge'
      return standard_roll   if @bonus.nil? && @malus.nil?
      return roll_with_bonus if @malus.nil?
      return roll_with_malus if @bonus.nil?
    end

    private

    def set_modifiers
      @bonus = (@base =~ /[Dd]\d+\+(\d+)/).nil? ? nil : @base.gsub(/[Dd]\d+\+/, '').to_i
      @malus = (@base =~ /[Dd]\d+\-(\d+)/).nil? ? nil : @base.gsub(/[Dd]\d+\-/, '').to_i
    end

    def base_check
      unless ['d', 'D', 'f', 'F'].include?(@base[0])
        raise ArgumentError.new("You can only create strandard and fudge dices.")
      end
    end

{'fraction_non_alphanumeric': 0.18903394255874673, 'fraction_numerical': 0.0026109660574412533, 'mean_word_length': 2.275213675213675, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6398724', 'n_tokens_mistral': 758, 'n_tokens_neox': 743, 'n_words': 174}