<commit_before>import React from 'react';

import Events from 'parser/core/Events';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import { formatNumber } from 'common/format';

import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';

import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';

const CHAIN_PROC_BUFFER = 200;
const HOLY_POWER_SPENDERS = [SPELLS.DIVINE_STORM, SPELLS.TEMPLARS_VERDICT, SPELLS.JUSTICARS_VENGEANCE_TALENT];

class DivinePurpose extends Analyzer {
  divinePurposeProcs = 0;
  templarsVerdictConsumptions = 0;
  divineStormConsumptions = 0;
  justicarsVengeanceConsumptions = 0;
  largestProcChain = 0;
  currentProcChain = 0;
  lastDivinePurposeConsumption = null;

  constructor(...args) {
    super(...args);
    this.active = this.selectedCombatant.hasTalent(SPELLS.DIVINE_PURPOSE_TALENT_RETRIBUTION.id);
  
    // event listeners
    this.addEventListener(Events.cast.by(SELECTED_PLAYER).spell(HOLY_POWER_SPENDERS), this.onCast);
    this.addEventListener(Events.applybuff.by(SELECTED_PLAYER).spell(SPELLS.DIVINE_PURPOSE_BUFF), this.onApplyDivinePurpose);
  }

  onCast(event){
    const spellId = event.ability.guid;
    if (!this.selectedCombatant.hasBuff(SPELLS.DIVINE_PURPOSE_BUFF.id)) {
      return;
    }
    this.lastDivinePurposeConsumption = event.timestamp;
    switch (spellId) {
      case SPELLS.TEMPLARS_VERDICT.id:
        this.templarsVerdictConsumptions += 1;
        break;
      case SPELLS.DIVINE_STORM.id:
        this.divineStormConsumptions += 1;
        break;
      case SPELLS.JUSTICARS_VENGEANCE_TALENT.id:
        this.justicarsVengeanceConsumptions += 1;
        break;
      default:
        break;
    }
  }

  onApplyDivinePurpose(event){
    this.divinePurposeProcs++;
    const timeSinceLastDPconsumption = event.timestamp - this.lastDivinePurposeConsumption;
    if (timeSinceLastDPconsumption < CHAIN_PROC_BUFFER) {
      if (this.currentProcChain === 0) {
        this.currentProcChain = 2;
      }
      else {
        this.currentProcChain += 1;
      }
      if (this.currentProcChain > this.largestProcChain){
        this.largestProcChain = this.currentProcChain;
      }
    }
    else {
      this.currentProcChain = 0;
    }
  }

  statistic() {
    const chainProcText = this.largestProcChain > 1 ? `Your longest chain of procs was ${this.largestProcChain}` : ``;
    return (
      <StatisticBox
        position={STATISTIC_ORDER.OPTIONAL(1)}
        icon={<SpellIcon id={SPELLS.DIVINE_PURPOSE_TALENT_RETRIBUTION.id} />}
        value={`${formatNumber(this.divinePurposeProcs)}`}
        label="Divine Purpose procs"
        tooltip={chainProcText}
      />
    );
  }
}

export default DivinePurpose;<commit_msg>Finishing Divine Purpose update<commit_after>import React from 'react';

import Events from 'parser/core/Events';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import { formatNumber } from 'common/format';

import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';

import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';

const CHAIN_PROC_BUFFER = 200;
const HOLY_POWER_SPENDERS = [SPELLS.DIVINE_STORM, SPELLS.TEMPLARS_VERDICT, SPELLS.JUSTICARS_VENGEANCE_TALENT];

class DivinePurpose extends Analyzer {
  divinePurposeProcs = 0;
  templarsVerdictConsumptions = 0;
  divineStormConsumptions = 0;
  justicarsVengeanceConsumptions = 0;
  largestProcChain = 0;
  currentProcChain = 0;
  lastDivinePurposeConsumption = null;

  constructor(...args) {
    super(...args);
    this.active = this.selectedCombatant.hasTalent(SPELLS.DIVINE_PURPOSE_TALENT_RETRIBUTION.id);
  
    // event listeners
    this.addEventListener(Events.cast.by(SELECTED_PLAYER).spell(HOLY_POWER_SPENDERS), this.onCast);
    this.addEventListener(Events.applybuff.by(SELECTED_PLAYER).spell(SPELLS.DIVINE_PURPOSE_BUFF), this.onApplyDivinePurpose);
  }

  onCast(event){
    const spellId = event.ability.guid;
    if (!this.selectedCombatant.hasBuff(SPELLS.DIVINE_PURPOSE_BUFF.id)) {
      return;
    }  
    switch (spellId) {
      case SPELLS.TEMPLARS_VERDICT.id:
        this.templarsVerdictConsumptions += 1;
        break;
      case SPELLS.DIVINE_STORM.id:
      // Empyrean Power grants a free Divine Storm and is prioritized over Divine Purpose if both are active
        if (this.selectedCombatant.hasBuff(SPELLS.EMPYREAN_POWER_BUFF.id)) {
          return;
        }
        this.divineStormConsumptions += 1;
        break;
      case SPELLS.JUSTICARS_VENGEANCE_TALENT.id:
        this.justicarsVengeanceConsumptions += 1;
        break;
      default:
        break;
    }
    this.lastDivinePurposeConsumption = event.timestamp;
  }

  onApplyDivinePurpose(event){
    this.divinePurposeProcs++;
    const timeSinceLastDPconsumption = event.timestamp - this.lastDivinePurposeConsumption;
    if (timeSinceLastDPconsumption < CHAIN_PROC_BUFFER) {
      if (this.currentProcChain === 0) {
        this.currentProcChain = 2;
      }
      else {
        this.currentProcChain += 1;
      }
      if (this.currentProcChain > this.largestProcChain){
        this.largestProcChain = this.currentProcChain;
      }
    }
    else {
      this.currentProcChain = 0;
    }
  }

  statistic() {
    const chainProcText = this.largestProcChain > 1 ? `<br>Your longest chain of procs was ${this.largestProcChain}` : ``;
    const justicarsVengeanceText = this.selectedCombatant.hasTalent(SPELLS.JUSTICARS_VENGEANCE_TALENT.id) ? `<br>Justicars Vengeance: ${this.justicarsVengeanceConsumptions}` : ``; 
    return (
      <StatisticBox
        position={STATISTIC_ORDER.OPTIONAL(1)}
        icon={<SpellIcon id={SPELLS.DIVINE_PURPOSE_TALENT_RETRIBUTION.id} />}
        value={`${formatNumber(this.divinePurposeProcs)}`}
        label="Divine Purpose procs"
        tooltip={`
          Your Divine Purpose procs were used on:<br>
          Templars Verdict: ${this.templarsVerdictConsumptions}<br>
          Divine Storm: ${this.divineStormConsumptions}
          ${justicarsVengeanceText}
          ${chainProcText}`}
      />
    );
  }
}

export default DivinePurpose;
{'fraction_non_alphanumeric': 0.10147751258321155, 'fraction_numerical': 0.0058451047247929854, 'mean_word_length': 3.522760646108664, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '7058857', 'n_tokens_mistral': 2167, 'n_tokens_neox': 2071, 'n_words': 331}