<commit_before>import React from 'react';

import SPELLS from 'common/SPELLS';
import ITEMS from 'common/ITEMS';

import Analyzer from 'Parser/Core/Analyzer';
import Combatants from 'Parser/Core/Modules/Combatants';
import SpellUsable from 'Parser/Core/Modules/SpellUsable';

const HIT_BUFFER_MS = 500;

class KiljaedensBurningWish extends Analyzer {
  static dependencies = {
    combatants: Combatants,
    spellUsable: SpellUsable,
  };

  hitTimestamp;
  casts = 0;
  hits = 0;
  damage = 0;

  on_initialized() {
    this.active = this.combatants.selected.hasTrinket(ITEMS.KILJAEDENS_BURNING_WISH.id);
  }

  on_byPlayer_damage(event) {
    if (event.ability.guid !== SPELLS.KILJAEDENS_BURNING_WISH_DAMAGE.id) {
      return;
    }

    this.hits += 1;
    // KJBW doesn't produce cast events when used, for whatever reason, so we guess them from damage events
    // Multiple damage events together is obviously the result of one cast, not several.
    if (!this.hitTimestamp || this.hitTimestamp + HIT_BUFFER_MS < event.timestamp) {
      this.hitTimestamp = event.timestamp;
      this.casts += 1;
      // obviously this is maybe a second after the actual cast, but it's close enough
      this.owner.triggerEvent('cast', this._fabricateCastFromDamage(event));
    }

    this.damage += event.amount + (event.absorbed || 0);
  }

  _fabricateCastFromDamage(event) {
    const castEvent = {};
    castEvent.timestamp = event.timestamp;
    castEvent.type = 'cast';
    castEvent.sourceID = event.sourceID;
    castEvent.sourceIsFriendly = event.sourceIsFriendly;
    castEvent.targetID = event.targetID;
    castEvent.targetIsFriendly = event.targetIsFriendly;

    castEvent.ability = event.ability;

    // TODO are these all the fields I need?

    return castEvent;
  }

  item() {
    return {
      item: ITEMS.KILJAEDENS_BURNING_WISH,
      result: (
        <dfn data-tip={`You got ${this.hits} hits over ${this.casts} casts, for an average of <b>${((this.hits / this.casts) || 0).toFixed(2)} hits per cast</b>`}>
        {this.owner.formatItemDamageDone(this.damage)}
        </dfn>
      ),
    };
  }
}

export default KiljaedensBurningWish;<commit_msg>Tweaked style of KJBW event fab<commit_after>import React from 'react';

import SPELLS from 'common/SPELLS';
import ITEMS from 'common/ITEMS';

import Analyzer from 'Parser/Core/Analyzer';
import Combatants from 'Parser/Core/Modules/Combatants';
import SpellUsable from 'Parser/Core/Modules/SpellUsable';

const HIT_BUFFER_MS = 500;

class KiljaedensBurningWish extends Analyzer {
  static dependencies = {
    combatants: Combatants,
    spellUsable: SpellUsable,
  };

  hitTimestamp;
  casts = 0;
  hits = 0;
  damage = 0;

  on_initialized() {
    this.active = this.combatants.selected.hasTrinket(ITEMS.KILJAEDENS_BURNING_WISH.id);
  }

  on_byPlayer_damage(event) {
    if (event.ability.guid !== SPELLS.KILJAEDENS_BURNING_WISH_DAMAGE.id) {
      return;
    }

    this.hits += 1;
    // KJBW doesn't produce cast events when used, for whatever reason, so we guess them from damage events
    // Multiple damage events together is obviously the result of one cast, not several.
    if (!this.hitTimestamp || this.hitTimestamp + HIT_BUFFER_MS < event.timestamp) {
      this.hitTimestamp = event.timestamp;
      this.casts += 1;
      // obviously this is maybe a second after the actual cast, but it's close enough
      this.owner.triggerEvent('cast', this._fabricateCastFromDamage(event));
    }

    this.damage += event.amount + (event.absorbed || 0);
  }

  _fabricateCastFromDamage(event) {
    return {
      timestamp: event.timestamp,
      type: 'cast',
      sourceID: event.sourceID,
      sourceIsFriendly: event.sourceIsFriendly,
      targetID: event.targetID,
      targetIsFriendly: event.targetIsFriendly,
      ability: event.ability,
    };
    // TODO are these all the fields I need?
  }

  item() {
    return {
      item: ITEMS.KILJAEDENS_BURNING_WISH,
      result: (
        <dfn data-tip={`You got ${this.hits} hits over ${this.casts} casts, for an average of <b>${((this.hits / this.casts) || 0).toFixed(2)} hits per cast</b>`}>
        {this.owner.formatItemDamageDone(this.damage)}
        </dfn>
      ),
    };
  }
}

export default KiljaedensBurningWish;
{'fraction_non_alphanumeric': 0.1112933458294283, 'fraction_numerical': 0.005154639175257732, 'mean_word_length': 3.3296146044624746, 'pattern_counts': {'":': 0, '<': 13, '<?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': '3867554', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1409, 'n_words': 337}