<commit_before>import React from 'react';

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

import SPELLS from 'common/SPELLS/index';
import SpellIcon from 'common/SpellIcon';

import { formatPercentage } from 'common/format';
import StatisticBox, { STATISTIC_ORDER } from 'Main/StatisticBox';
import SCHOOLS from 'common/MAGIC_SCHOOLS';
import SpellUsable from 'Parser/Core/Modules/SpellUsable';

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

  hitsWithDS = 0;
  hitsWithoutDS = 0;
  hitsWithDSOnCD = 0;

  on_toPlayer_damage(event) {
    // Physical
    if (event.ability.type !== SCHOOLS.ids.PHYSICAL) {
      return;
    }
    if (this.combatants.selected.hasBuff(SPELLS.DEMON_SPIKES_BUFF.id, event.timestamp)) {
      this.hitsWithDS += 1;
    }else{
      this.hitsWithoutDS += 1;

      const onCooldown = this.spellUsable.isOnCooldown(SPELLS.DEMON_SPIKES.id);
      if(onCooldown) {
        this.hitsWithDSOnCD += 1;
      }
    }
  }

  get mitigatedUptime(){
    return formatPercentage(this.hitsWithDS / (this.hitsWithDS + this.hitsWithoutDS));
  }

  statistic() {
    const demonSpikesUptime = this.combatants.selected.getBuffUptime(SPELLS.DEMON_SPIKES_BUFF.id);

    const demonSpikesUptimePercentage = demonSpikesUptime / this.owner.fightDuration;

    return (
      <StatisticBox
        icon={<SpellIcon id={SPELLS.DEMON_SPIKES.id} />}
        value={`${this.mitigatedUptime}%`}
        label="Hits Mitigated by Demon Spikes"
        tooltip={`Demon Spikes usage breakdown:
          <ul>
          <li>You were hit <b>${this.hitsWithDS}</b> times with your Demon Spikes buff.</li>
          <li>You were hit <b>${this.hitsWithoutDS}</b> times <b><i>without</i></b> your Demon Spikes buff.</li>
          <li>You were hit <b>${this.hitsWithDSOnCD}</b> times <b><i>with</i></b> Demon Spikes avalible for use but not used.</li>
          </ul>
          <b>${this.mitigatedUptime}%</b> of physical attacks were mitigated with Demon Spikes, and your overall uptime was <b>${formatPercentage(demonSpikesUptimePercentage)}%</b>.`}
      />
    );
  }
  statisticOrder = STATISTIC_ORDER.CORE(7);
}

export default DemonSpikes;
<commit_msg>Updates requested in the PR<commit_after>import React from 'react';

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

import SPELLS from 'common/SPELLS/index';
import SpellIcon from 'common/SpellIcon';

import { formatPercentage } from 'common/format';
import StatisticBox, { STATISTIC_ORDER } from 'Main/StatisticBox';
import SCHOOLS from 'common/MAGIC_SCHOOLS';
import SpellUsable from 'Parser/Core/Modules/SpellUsable';

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

  hitsWithDS = 0;
  hitsWithoutDS = 0;
  hitsWithDSOffCD = 0;

  on_toPlayer_damage(event) {
    // Physical
    if (event.ability.type !== SCHOOLS.ids.PHYSICAL) {
      return;
    }
    if (this.combatants.selected.hasBuff(SPELLS.DEMON_SPIKES_BUFF.id, event.timestamp)) {
      this.hitsWithDS += 1;
    }else{
      this.hitsWithoutDS += 1;

      const onCooldown = this.spellUsable.isOnCooldown(SPELLS.DEMON_SPIKES.id);
      if(onCooldown) {
        this.hitsWithDSOffCD += 1;
      }
    }
  }

  get mitigatedUptime(){
    return formatPercentage(this.hitsWithDS / (this.hitsWithDS + this.hitsWithoutDS));
  }

  statistic() {
    const demonSpikesUptime = this.combatants.selected.getBuffUptime(SPELLS.DEMON_SPIKES_BUFF.id);

    const demonSpikesUptimePercentage = demonSpikesUptime / this.owner.fightDuration;

    return (
      <StatisticBox
        icon={<SpellIcon id={SPELLS.DEMON_SPIKES.id} />}
        value={`${this.mitigatedUptime}%`}
        label="Hits Mitigated by Demon Spikes"
        tooltip={`Demon Spikes usage breakdown:
          <ul>
          <li>You were hit <b>${this.hitsWithDS}</b> times with your Demon Spikes buff.</li>
          <li>You were hit <b>${this.hitsWithoutDS}</b> times <b><i>without</i></b> your Demon Spikes buff.</li>
          <li>You were hit <b>${this.hitsWithDSOffCD}</b> times <b><i>with</i></b> Demon Spikes avalible for use but not used.</li>
          </ul>
          <b>Your overall uptime was <b>${formatPercentage(demonSpikesUptimePercentage)}%</b>.`}
      />
    );
  }
  statisticOrder = STATISTIC_ORDER.CORE(7);
}

export default DemonSpikes;

{'fraction_non_alphanumeric': 0.12638827187916482, 'fraction_numerical': 0.003109729009329187, 'mean_word_length': 3.4985014985014984, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 58, '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': '4229140', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1602, 'n_words': 308}