<commit_before>import React from 'react';
import Analyzer from 'Parser/Core/Analyzer';
import Combatants from 'Parser/Core/Modules/Combatants';
import SPELLS from 'common/SPELLS';
import SpellUsable from 'Parser/Core/Modules/SpellUsable';
import StatisticBox from "Main/StatisticBox";
import SpellIcon from "common/SpellIcon";
import SpellLink from "common/SpellLink";

const debug = false;

const TITANS_THUNDER_USE_REGARDLESS_THRESHHOLD = 30;

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

  goodTTCasts = 0;
  badTTCasts = 0;
  _currentStacks = 0;
  totalTTCasts = 0;
  stacksOnTTCast = 0;
  shouldHaveSavedTT = 0;

  on_toPlayer_applybuff(event) {
    const buffId = event.ability.guid;
    if (buffId !== SPELLS.DIRE_BEAST_BUFF.id) {
      return;
    }
    this._currentStacks += 1;
  }
  on_toPlayer_removebuff(event) {
    const buffId = event.ability.guid;
    if (buffId !== SPELLS.DIRE_BEAST_BUFF.id) {
      return;
    }
    this._currentStacks -= 1;
  }

  on_byPlayer_cast(event) {
    const spellId = event.ability.guid;
    if (spellId !== SPELLS.TITANS_THUNDER.id) {
      return;
    }
    debug && console.log(`stacks:`, this._currentStacks);
    this.totalTTCasts += 1;
    if (this.spellUsable.cooldownRemaining(SPELLS.BESTIAL_WRATH.id) < TITANS_THUNDER_USE_REGARDLESS_THRESHHOLD) {
      this.shouldHaveSavedTT += 1;
      return;
    }
    if (!this.combatants.selected.hasTalent(SPELLS.DIRE_FRENZY_TALENT.id)) {
      if (this.combatants.selected.hasBuff(SPELLS.DIRE_BEAST_BUFF.id)) {
        this.goodTTCasts += 1;
        this.stacksOnTTCast += this._currentStacks;
      } else {
        this.badTTCasts += 1;
      }
    } else {
      if (this.combatants.selected.hasBuff(SPELLS.BESTIAL_WRATH.id)) {
        debug && console.log(`in good tt casts`);
        this.goodTTCasts += 1;
      } else {
        this.badTTCasts += 1;
      }
    }
  }
  statistic() {
    return (
      <StatisticBox
        icon={<SpellIcon id={SPELLS.TITANS_THUNDER.id} />}
        value={(
          <span>
            {this.goodTTCasts}{'  '}
            <SpellIcon
              id={SPELLS.TITANS_THUNDER.id}
              style={{
                height: '1.3em',
                marginTop: '-.1em',
              }}
            />
            <br />
            {this.badTTCasts}{'  '}
            <SpellIcon
              id={SPELLS.TITANS_THUNDER.id}
              style={{
                height: '1.3em',
                marginTop: '-.1em',
                filter: 'grayscale(100%)',
              }}
            />
          </span>

        )}
        label={`Titan's Thunder information`}
        tooltip={`You cast Titan's Thunder ${this.totalTTCasts} times, of which ${this.badTTCasts} were bad casts. <br/> Bad casts indicate that they were used without Dire Beasts up, or if you are using Dire Frenzy, then Titan's Thunder was used without Bestial Wrath up. <br/> You cast Titan's Thunder ${this.shouldHaveSavedTT} times where you should have delayed casting it, this occurs when you cast Titan's Thunder when there is less than 30 seconds remaning on Bestial Wrath cooldown.`}
      />
    );
  }
  suggestions(when) {
    when(this.badTTCasts).isGreaterThan(0)
      .addSuggestion((suggest, actual, recommended) => {
        return suggest(<span>Don't cast <SpellLink id={SPELLS.TITANS_THUNDER.id} /> without <SpellLink id={SPELLS.DIRE_BEAST.id} /> up, or if using <SpellLink id={SPELLS.DIRE_FRENZY_TALENT.id} /> without <SpellLink id={SPELLS.BESTIAL_WRATH.id} /> up.</span>)<commit_msg>minor wording<commit_after>import React from 'react';
import Analyzer from 'Parser/Core/Analyzer';
import Combatants from 'Parser/Core/Modules/Combatants';
import SPELLS from 'common/SPELLS';
import SpellUsable from 'Parser/Core/Modules/SpellUsable';
import StatisticBox from "Main/StatisticBox";
import SpellIcon from "common/SpellIcon";
import SpellLink from "common/SpellLink";

const debug = false;

const TITANS_THUNDER_USE_REGARDLESS_THRESHHOLD = 30;

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

  goodTTCasts = 0;
  badTTCasts = 0;
  _currentStacks = 0;
  totalTTCasts = 0;
  stacksOnTTCast = 0;
  shouldHaveSavedTT = 0;

  on_toPlayer_applybuff(event) {
    const buffId = event.ability.guid;
    if (buffId !== SPELLS.DIRE_BEAST_BUFF.id) {
      return;
    }
    this._currentStacks += 1;
  }
  on_toPlayer_removebuff(event) {
    const buffId = event.ability.guid;
    if (buffId !== SPELLS.DIRE_BEAST_BUFF.id) {
      return;
    }
    this._currentStacks -= 1;
  }

  on_byPlayer_cast(event) {
    const spellId = event.ability.guid;
    if (spellId !== SPELLS.TITANS_THUNDER.id) {
      return;
    }
    debug && console.log(`stacks:`, this._currentStacks);
    this.totalTTCasts += 1;
    if (this.spellUsable.cooldownRemaining(SPELLS.BESTIAL_WRATH.id) < TITANS_THUNDER_USE_REGARDLESS_THRESHHOLD) {
      this.shouldHaveSavedTT += 1;
      return;
    }
    if (!this.combatants.selected.hasTalent(SPELLS.DIRE_FRENZY_TALENT.id)) {
      if (this.combatants.selected.hasBuff(SPELLS.DIRE_BEAST_BUFF.id)) {
        this.goodTTCasts += 1;
        this.stacksOnTTCast += this._currentStacks;
      } else {
        this.badTTCasts += 1;
      }
    } else {
      if (this.combatants.selected.hasBuff(SPELLS.BESTIAL_WRATH.id)) {
        debug && console.log(`in good tt casts`);
        this.goodTTCasts += 1;
      } else {
        this.badTTCasts += 1;
      }
    }
  }
  statistic() {
    return (
      <StatisticBox
        icon={<SpellIcon id={SPELLS.TITANS_THUNDER.id} />}
        value={(
          <span>
            {this.goodTTCasts}{'  '}
            <SpellIcon
              id={SPELLS.TITANS_THUNDER.id}
              style={{
                height: '1.3em',
                marginTop: '-.1em',
              }}
            />
            <br />
            {this.badTTCasts}{'  '}
            <SpellIcon
              id={SPELLS.TITANS_THUNDER.id}
              style={{
                height: '1.3em',
                marginTop: '-.1em',
                filter: 'grayscale(100%)',
              }}
            />
          </span>

        )}
        label={`Titan's Thunder`}
        tooltip={`You cast Titan's Thunder ${this.totalTTCasts} times, of which ${this.badTTCasts} were bad casts. <br/> Bad casts indicate that they were used without Dire Beasts up, or if you are using Dire Frenzy, then Titan's Thunder was used without Bestial Wrath up. <br/> You cast Titan's Thunder ${this.shouldHaveSavedTT} times where you should have delayed casting it, this occurs when you cast Titan's Thunder when there is less than 30 seconds remaning on Bestial Wrath cooldown.`}
      />
    );
  }
  suggestions(when) {
    when(this.badTTCasts).isGreaterThan(0)
      .addSuggestion((suggest, actual, recommended) => {
        return suggest(<span>Don't cast <SpellLink id={SPELLS.TITANS_THUNDER.id} /> without <SpellLink id={SPELLS.DIRE_BEAST.id} /> up, or if using <SpellLink id={SPELLS.DIRE_FRENZY_TALENT.id} /> without <SpellLink id={SPELLS.BESTIAL_WRATH.id} /> up.</span>)
{'fraction_non_alphanumeric': 0.11946532999164577, 'fraction_numerical': 0.007797270955165692, 'mean_word_length': 2.5541810984661057, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '2013685', 'n_tokens_mistral': 2587, 'n_tokens_neox': 2484, 'n_words': 497}