<commit_before>function evalMiss(combat) {
  if (combat.numberOfCreatureHitsTillDead - combat.numberOfHitsRequired <= 1) {
    return ', dies on miss';
  }
  return ', survives a miss';
}

function canIHit(combat) {
  return combat.numberOfHitsRequired === '-' ||
    combat.numberOfHitsRequired > combat.numberOfCreatureHitsTillDead;
}

function evalPlayerHits(combat) {
  if (combat.numberOfCreatureHitsTillDead === '-') {
    return combat.numberOfHitsRequired;
  } else if (canIHit(combat)) {
    return '-';
  }
  return combat.numberOfHitsRequired;
}

function canCreatureHit(combat) {
  return combat.numberOfCreatureHitsTillDead === '-' ||
    combat.numberOfCreatureHitsTillDead > combat.numberOfHitsRequired;
}

function evalCreatureHits(combat) {
  if (combat.numberOfHitsRequired === '-') {
    return combat.numberOfCreatureHitsTillDead;
  } else if (canCreatureHit(combat)) {
    return '-';
  }
  return combat.numberOfCreatureHitsTillDead;
}

var evalFightStatus = [
  {
    test: function(combat) {
      return combat.playerHits === '-' && combat.creatureHits === '-';
    },
    fStatus: function() {return 'Unresolved';}
  },
  {
    test: function(combat) {return combat.playerHits === '-';},
    fStatus: function() {return 'Player dies';}
  },
  {
    test: function(combat) {return combat.playerHits === 1;},
    fStatus: function(combat) {return 'Player 1 hits' + evalMiss(combat);}
  },
  {
    test: function(combat) {return combat.playerHits > 1;},
    fStatus: function(combat) {return 'Player > 1 hits' + evalMiss(combat);}
  }
];

export default function evalAnalysis(combat) {
  // Analysis:
  combat.playerHits = evalPlayerHits(combat);
  combat.creatureHits = evalCreatureHits(combat);
  for (var i = 0; i < evalFightStatus.length; i += 1) {
    if (evalFightStatus[i].test(combat)) {
      combat.fightStatus = evalFightStatus[i].fStatus(combat);
      return;
    }
  }
  combat.fightStatus = 'Unknown';
}<commit_msg>Try to tidy up combat analysis<commit_after>function evalMiss(combat) {
  if (combat.numberOfCreatureHitsTillDead - combat.numberOfHitsRequired <= 1) {
    return ', dies on miss';
  }
  return ', survives a miss';
}

function canIHit(combat) {
  return combat.numberOfHitsRequired === '-' ||
    combat.numberOfHitsRequired > combat.numberOfCreatureHitsTillDead;
}

function evalPlayerHits(combat) {
  if (combat.numberOfCreatureHitsTillDead === '-') {
    return combat.numberOfHitsRequired;
  } else if (canIHit(combat)) {
    return '-';
  }
  return combat.numberOfHitsRequired;
}

function canCreatureHit(combat) {
  return combat.numberOfCreatureHitsTillDead === '-' ||
    combat.numberOfCreatureHitsTillDead > combat.numberOfHitsRequired;
}

function evalCreatureHits(combat) {
  if (combat.numberOfHitsRequired === '-') {
    return combat.numberOfCreatureHitsTillDead;
  } else if (canCreatureHit(combat)) {
    return '-';
  }
  return combat.numberOfCreatureHitsTillDead;
}

var evalFightStatus = [
  {
    test: function(combat) {
      return combat.playerHits === '-' && combat.creatureHits === '-';
    },
    fStatus: function() {return 'Unresolved';}
  },
  {
    test: function(combat) {return combat.playerHits === '-';},
    fStatus: function() {return 'Player dies';}
  },
  {
    test: function(combat) {return combat.playerHits === 1;},
    fStatus: function(combat) {return 'Player 1 hits' + evalMiss(combat);}
  },
  {
    test: function(combat) {return combat.playerHits > 1;},
    fStatus: function(combat) {return 'Player > 1 hits' + evalMiss(combat);}
  }
];

export default function evalAnalysis(combat) {
  // Analysis:
  combat.playerHits = evalPlayerHits(combat);
  combat.creatureHits = evalCreatureHits(combat);
  var status = evalFightStatus.find(function(el) {return el.test(combat);});
  if (status) {
    combat.fightStatus = status.fStatus(combat);
  } else {
    combat.fightStatus = 'Unknown';
  }
}
{'fraction_non_alphanumeric': 0.14168377823408623, 'fraction_numerical': 0.003080082135523614, 'mean_word_length': 4.16158940397351, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 11, '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': '6979356', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1344, 'n_words': 238}