<commit_before># Stattr includes some basic functions that could be used in a Tabletop RPG application
#
# @author <NAME>

module Stattr

  # The Class that defines, in other applications, the "rules" of that game - the stats, the  sides of a given die, and so on.
  #
  class Game

    # How many sides the generating dice have in this game.
    #
    # @return [Integer]
    #
    def self.dice_sides
      6
    end #self.dice_sides

    # The number of dice required to create a stat in this game
    #
    # @return [Integer]
    #
    def self.dice_num
      3
    end #self.dice_num

    # The list of stats for this game.
    #
    # @return [Array]
    #
    def self.stats
      ["str", "con", "wis", "int", "cha", "dex"]
    end #self.stats
  end #Game

  # Represents a single instance of the result of a dice roll
  #
  class DiceRoll

    # @attribute sides [Integer] The number of sides the dice in this roll have.
    # @attribute count [Integer] The number of die being rolled.
    #
    attr_accessor :sides, :count

    # New instance of DiceRoll.
    #
    # @param [Integer] sides
    # @param [Integer] count
    # @return [Object] DiceRoll object
    #
    #def initialize(sides=DICE_SIDES, count=1)
    def initialize(sides=Game.dice_sides, count=Game.dice_num)
      @sides = sides
      @count = count
    end #initialize

    # Roll a new die.
    #
    # @param [Integer] sides
    # @param [Integer] count
    # @return [Object] DiceRoll object
    #
    def self.new_roll(sides = Game.dice_sides, count=Game.dice_num)
      # make a new dice object, then roll it.
      new(sides, count).roll
    end #self.roll

    # From 1 to count, that many [sides] sided die.
    #
    # @return [Integer] Gives each outcome to Roll.
    #
    def rolls
      (1..count).map { |d| rand(sides) + 1 }
    end #rolls

    # Adds the rolls from rolls together.
    #
    # @return [Integer] combined rolls
    #
    def roll
      rolls.inject(0) { |total, d| total += d }
    end #roll
  end #DiceRoll

  # Represents the list of Statistics that a player has.
  #
  class StatList

    # Creates an attr_accessor for each stat in STAT
    #
    # @attribute STATS [Integer] any number of Stats.
    #
    attr_accessor *Game.stats

    # Creates a new StatList object. each stat in STAT is an attribute, with the result of makestat assigned to it
    #
    def initialize
       Game.stats.each { |s| instance_variable_set("@#{s}", make_stat) }
    end #initialize

    # Allow manual setting of stats.
    #
    # @param [Attribute] stat
    # @param [Integer] val
    #
    def set_stat(stat, val)
      send "#{stat}=", modstat(val)
    end

    # Creates stat/mod array.
    #
    # @return [Array] modlist. [0] is the stat, [1] is the modifier.
    #
    def modstat(r)
      modr = ((r-10)/2).to_int
      modlist = [r, modr]
    end #modstat

    # makes a Stat/mod combination
    #
    # @return [Array]
    #
    def make_stat
      modstat(DiceRoll.new_roll(Game.dice_sides, Game.dice_num))
    end #make_stat
  end #StatList

  # CharacterSheet of a given PlayerCharacter.
  #
  class CharacterSheet

    # @attribute stats [Object] A StatList object
    # @attribute name [String] The Player Character's name
    #
    attr_accessor :stats, :name
<commit_msg>stats are now their own class<commit_after># Stattr includes some basic functions that could be used in a Tabletop RPG application
#
# @author <NAME>

module Stattr

  # The Class that defines, in other applications, the "rules" of that game - the stats, the  sides of a given die, and so on.
  #
  class Game

    # How many sides the generating dice have in this game.
    #
    # @return [Integer]
    #
    def self.dice_sides
      6
    end #self.dice_sides

    # The number of dice required to create a stat in this game
    #
    # @return [Integer]
    #
    def self.dice_num
      3
    end #self.dice_num

    def self.make_stat
      DiceRoll.new_roll(Game.dice_sides, Game.dice_num)
    end #make_stat

    # The list of stats for this game.
    #
    # @return [Array]
    #
    def self.stats
      ["str", "con", "wis", "int", "cha", "dex"]
    end #self.stats
  end #Game

  # Represents a single instance of the result of a dice roll
  #
  class DiceRoll

    # @attribute sides [Integer] The number of sides the dice in this roll have.
    # @attribute count [Integer] The number of die being rolled.
    #
    attr_accessor :sides, :count

    # New instance of DiceRoll.
    #
    # @param [Integer] sides
    # @param [Integer] count
    # @return [Object] DiceRoll object
    #
    #def initialize(sides=DICE_SIDES, count=1)
    def initialize(sides=Game.dice_sides, count=Game.dice_num)
      @sides = sides
      @count = count
    end #initialize

    # Roll a new die.
    #
    # @param [Integer] sides
    # @param [Integer] count
    # @return [Object] DiceRoll object
    #
    def self.new_roll(sides = Game.dice_sides, count=Game.dice_num)
      # make a new dice object, then roll it.
      new(sides, count).roll
    end #self.roll

    # From 1 to count, that many [sides] sided die.
    #
    # @return [Integer] Gives each outcome to Roll.
    #
    def rolls
      (1..count).map { |d| rand(sides) + 1 }
    end #rolls

    # Adds the rolls from rolls together.
    #
    # @return [Integer] combined rolls
    #
    def roll
      rolls.inject(0) { |total, d| total += d }
    end #roll
  end #DiceRoll

  # Represents the list of Statistics that a player has.
  #
  class StatList

    # Creates an attr_accessor for each stat in STAT
    #
    # @attribute STATS [Integer] any number of Stats.
    #
    attr_accessor *Game.stats

    # Creates a new StatList object. each stat in STAT is an attribute, with the result of makestat assigned to it
    #
    def initialize
       Game.stats.each { |s| instance_variable_set("@#{s}", Stat.new(Game.make_stat)) }
    end #initialize

    # Allow manual setting of stats.
    #
    # @param [Attribute] stat
    # @param [Integer] val
    #
    def set_stat(stat, value)
      send "#{stat}=", modstat(value)
    end #set_stat
  end #StatList

  class Stat
    attr_accessor :val, :mod

    def initialize(value)
      @val= value
      @mod= modstat(value)
    end
    # Creates stat/mod array.
    #
    # @return [Array] modlist. [0] is the stat, [1] is the modifier.
    #
    def modstat(r)
      modr = ((r-10)/2).to_int
    end #modstat

    # makes a Stat/mod combination
    #
    # @return [Array]
    #
  end #Stat

  # CharacterSheet of a given PlayerCharacter.
  #
  class CharacterSheet

    # @attribute stats [Object] A StatList object
    # @attribute name [String] The Player Character's name
    #
    attr_accessor :stats, :name

{'fraction_non_alphanumeric': 0.09723461195361284, 'fraction_numerical': 0.003568242640499554, 'mean_word_length': 2.3872104733131922, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '174045', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2193, 'n_words': 765}