<commit_before>import _ from "lodash"

export default class CombatDetection {

  constructor(units) {
    this.units = units
  }

  getCombats() {
    const unitColor = unit => unit.getPlayer().getColor()
    const unitsByColor = Object.values(_.groupBy(this.units, unitColor))
    if (unitsByColor.length < 2) {
      return []
    }
    return this._getCollisionPairs(unitsByColor[0], unitsByColor[1])
  }

  _getCollisionPairs(unitsA, unitsB) {
    let collisionPairs = []
    for (let aIndex = 0; aIndex < unitsA.length; aIndex++) {
      for (let bIndex = 0; bIndex < unitsB.length; bIndex++) {
        const unitFromA = unitsA[aIndex]
        const unitFromB = unitsB[bIndex]
        if (unitFromA.collidesWith(unitFromB)) {
          collisionPairs.push([unitFromA, unitFromB])
        }
      }
    }
    return collisionPairs
  }

}<commit_msg>Renamed unitColor variable for clarity<commit_after>import _ from "lodash"

export default class CombatDetection {

  constructor(units) {
    this.units = units
  }

  getCombats() {
    const getUnitColor = unit => unit.getPlayer().getColor()
    const unitsByColor = Object.values(_.groupBy(this.units, getUnitColor))
    if (unitsByColor.length < 2) {
      return []
    }
    return this._getCollisionPairs(unitsByColor[0], unitsByColor[1])
  }

  _getCollisionPairs(unitsA, unitsB) {
    let collisionPairs = []
    for (let aIndex = 0; aIndex < unitsA.length; aIndex++) {
      for (let bIndex = 0; bIndex < unitsB.length; bIndex++) {
        const unitFromA = unitsA[aIndex]
        const unitFromB = unitsB[bIndex]
        if (unitFromA.collidesWith(unitFromB)) {
          collisionPairs.push([unitFromA, unitFromB])
        }
      }
    }
    return collisionPairs
  }

}
{'fraction_non_alphanumeric': 0.11514104778353483, 'fraction_numerical': 0.0057570523891767415, 'mean_word_length': 2.995402298850575, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4101303', 'n_tokens_mistral': 586, 'n_tokens_neox': 569, 'n_words': 116}