<commit_before>import React from 'react';

import SPELLS from 'common/SPELLS/index';
import { calculateAzeriteEffects } from 'common/stats';
import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
import TraitStatisticBox, { STATISTIC_ORDER } from 'interface/others/TraitStatisticBox';
import ItemDamageDone from 'interface/others/ItemDamageDone';
import Events from 'parser/core/Events';
import HIT_TYPES from 'game/HIT_TYPES';
import { formatNumber } from 'common/format';

const whispersOfTheDamnedStats = traits => Object.values(traits).reduce((obj, rank) => {
  const [damage] = calculateAzeriteEffects(SPELLS.WHISPERS_OF_THE_DAMNED.id, rank);
  obj.damage += damage;
  return obj;
}, {
  damage: 0,
});

const MIND_BLAST_SPELLS = [
  SPELLS.MIND_BLAST,
  SPELLS.SHADOW_WORD_VOID_TALENT,
];

/**
 * Whispers of the Damned
 * Mind Blast deals 2704 additional damage and generates 20 additional Insanity on critical strikes.
 *
 * Example log: /report/JQNwLbpdtmrzYAGC/5-Mythic+Blackwater+Behemoth+-+Kill+(5:09)/Adoraci
 */
class WhispersOfTheDamned extends Analyzer {
  damageValue = 0;
  damageDone = 0;
  insanityGained = 0;

  constructor(...args) {
    super(...args);
    this.active = this.selectedCombatant.hasTrait(SPELLS.WHISPERS_OF_THE_DAMNED.id);
    this.addEventListener(Events.damage.by(SELECTED_PLAYER).spell(MIND_BLAST_SPELLS), this.onDamageEvent);
    if (!this.active) {
      return;
    }

    const { damage } = whispersOfTheDamnedStats(this.selectedCombatant.traitsBySpellId[SPELLS.WHISPERS_OF_THE_DAMNED.id]);
    this.damageValue = damage;
  }

  onDamageEvent(event) {
    this.damageDone += this.damageValue;

    if (event.hitType === HIT_TYPES.CRIT) {
      this.insanityGained += 20;
    }
  }

  statistic() {
    return (<commit_msg>Switch event listener and early return<commit_after>import React from 'react';

import SPELLS from 'common/SPELLS/index';
import { calculateAzeriteEffects } from 'common/stats';
import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
import TraitStatisticBox, { STATISTIC_ORDER } from 'interface/others/TraitStatisticBox';
import ItemDamageDone from 'interface/others/ItemDamageDone';
import Events from 'parser/core/Events';
import HIT_TYPES from 'game/HIT_TYPES';
import { formatNumber } from 'common/format';

const whispersOfTheDamnedStats = traits => Object.values(traits).reduce((obj, rank) => {
  const [damage] = calculateAzeriteEffects(SPELLS.WHISPERS_OF_THE_DAMNED.id, rank);
  obj.damage += damage;
  return obj;
}, {
  damage: 0,
});

const MIND_BLAST_SPELLS = [
  SPELLS.MIND_BLAST,
  SPELLS.SHADOW_WORD_VOID_TALENT,
];

/**
 * Whispers of the Damned
 * Mind Blast deals 2704 additional damage and generates 20 additional Insanity on critical strikes.
 *
 * Example log: /report/JQNwLbpdtmrzYAGC/5-Mythic+Blackwater+Behemoth+-+Kill+(5:09)/Adoraci
 */
class WhispersOfTheDamned extends Analyzer {
  damageValue = 0;
  damageDone = 0;
  insanityGained = 0;

  constructor(...args) {
    super(...args);
    this.active = this.selectedCombatant.hasTrait(SPELLS.WHISPERS_OF_THE_DAMNED.id);
    if (!this.active) {
      return;
    }
    this.addEventListener(Events.damage.by(SELECTED_PLAYER).spell(MIND_BLAST_SPELLS), this.onDamageEvent);

    const { damage } = whispersOfTheDamnedStats(this.selectedCombatant.traitsBySpellId[SPELLS.WHISPERS_OF_THE_DAMNED.id]);
    this.damageValue = damage;
  }

  onDamageEvent(event) {
    this.damageDone += this.damageValue;

    if (event.hitType === HIT_TYPES.CRIT) {
      this.insanityGained += 20;
    }
  }

  statistic() {
    return (
{'fraction_non_alphanumeric': 0.11840268081541469, 'fraction_numerical': 0.008936051382295447, 'mean_word_length': 4.667721518987341, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6650131', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1284, 'n_words': 229}