<commit_before>module Skirmish::BattleSimulator
  class BattleResult
    def initialize(attacker_won, defender_won)
      @defender_won = defender_won
      @attacker_won = attacker_won
    end

    def attacker_won?
      @attacker_won
    end

    def defender_won?
      @defender_won
    end
  end

  def self.resolve_battle(attacking_units, defending_city)
    until attacking_units.empty? || defending_city.units.empty?
      attacker_roll = rand(1..6)
      defender_roll = rand(1..6)
      if attacker_roll > defender_roll
        defending_city.units.first.destroy
      else
        attacking_units.first.destroy
      end
    end
    BattleResult.new(attacking_units.empty?, defending_city.units.empty?)
  end
end<commit_msg>Made battle simulator use Random.rand instead of rand for stubability<commit_after>module Skirmish::BattleSimulator
  class BattleResult
    def initialize(attacker_won, defender_won)
      @defender_won = defender_won
      @attacker_won = attacker_won
    end

    def attacker_won?
      @attacker_won
    end

    def defender_won?
      @defender_won
    end
  end

  def self.resolve_battle(attacking_units, defending_city)
    until attacking_units.empty? || defending_city.units.empty?
      attacker_roll = Random.rand(1..6)
      defender_roll = Random.rand(1..6)
      if attacker_roll > defender_roll
        defending_city.units.first.destroy
      else
        attacking_units.first.destroy
      end
    end
    BattleResult.new(attacking_units.empty?, defending_city.units.empty?)
  end
end
{'fraction_non_alphanumeric': 0.06939040207522698, 'fraction_numerical': 0.005188067444876783, 'mean_word_length': 3.092838196286472, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1188708', 'n_tokens_mistral': 491, 'n_tokens_neox': 476, 'n_words': 94}