<commit_before>import React from 'react';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import SpellIcon from 'common/SpellIcon';
import { formatPercentage } from 'common/format';
import Module from 'Parser/Core/Module';
import StatisticBox, { STATISTIC_ORDER } from 'Main/StatisticBox';

class IronSkinBrew extends Module {

  suggestions(when) {
    const isbUptimePercentage = this.owner.selectedCombatant.getBuffUptime(SPELLS.IRONSKIN_BREW_BUFF.id)/ this.owner.fightDuration;

    when(isbUptimePercentage).isLessThan(0.9)
      .addSuggestion((suggest, actual, recommended) => {
        return suggest(<span> Your <SpellLink id={SPELLS.IRONSKIN_BREW.id} /> uptime was {formatPercentage(isbUptimePercentage)}%, unless there are extended periods of downtime it should be over should be near 100%.</span>)
          .icon(SPELLS.IRONSKIN_BREW.icon)
          .actual(`${formatPercentage(isbUptimePercentage)}% uptime`)
          .recommended(`${Math.round(formatPercentage(recommended))}% or more is recommended`)
          .regular(recommended - 0.1).major(recommended - 0.2);
      });
  }

  statistic() {
    const isbUptime = this.owner.selectedCombatant.getBuffUptime(SPELLS.IRONSKIN_BREW_BUFF.id)/ this.owner.fightDuration;
    return (
      <StatisticBox
        icon={<SpellIcon id={SPELLS.IRONSKIN_BREW.id} />}
        value={`${formatPercentage(isbUptime)}%`}
        label='Ironskin Brew uptime'
      />
    );
  }
  statisticOrder = STATISTIC_ORDER.OPTIONAL();
}

export default IronSkinBrew;
<commit_msg>Added a tooltip to ISB to include similar information to IronFur<commit_after>import React from 'react';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import SpellIcon from 'common/SpellIcon';
import { formatPercentage, formatThousands } from 'common/format';
import Module from 'Parser/Core/Module';
import StatisticBox, { STATISTIC_ORDER } from 'Main/StatisticBox';

const debug = false;

class IronSkinBrew extends Module {

  lastIronSkinBrewBuffApplied = 0;

  hitsWithIronSkinBrew = 0;
  damageWithIronSkinBrew = 0;
  hitsWithoutIronSkinBrew = 0;
  damageWithoutIronSkinBrew = 0;
  
  // This value is just for dev purposes to check the total, its not shown on the tooltip.
  staggerDot = 0;

  on_byPlayer_applybuff(event) {
    const spellId = event.ability.guid;
    if (SPELLS.IRONSKIN_BREW_BUFF.id === spellId) {
      this.lastIronSkinBrewBuffApplied = event.timestamp;
    }
  }

  on_byPlayer_removebuff(event) {
    const spellId = event.ability.guid;
    if (SPELLS.IRONSKIN_BREW_BUFF.id === spellId) {
      this.lastIronSkinBrewBuffApplied = 0;
    }
  }
  
  on_toPlayer_damage(event) {
    if (event.ability.guid !== SPELLS.STAGGER_TAKEN.id) {
      if (this.lastIronSkinBrewBuffApplied > 0) {
        this.hitsWithIronSkinBrew++;
        this.damageWithIronSkinBrew += event.amount + (event.absorbed || 0) + (event.overkill || 0);
      }
      else {
        this.hitsWithoutIronSkinBrew++;
        this.damageWithoutIronSkinBrew += event.amount + (event.absorbed || 0) + (event.overkill || 0);
      }
    }
    else {
      this.staggerDot += event.amount + (event.absorbed || 0) + (event.overkill || 0);
    }
  }

  on_toPlayer_absorbed(event) {
    if (event.ability.guid === SPELLS.STAGGER.id) {
      if (this.lastIronSkinBrewBuffApplied > 0) {
        this.damageWithIronSkinBrew -= event.amount;
      }
      else {
        this.damageWithoutIronSkinBrew -= event.amount;
      }
    }
  }

  on_finished() {
    if (debug) {
      console.log('Hits with IronSkinBrew ' + this.hitsWithIronSkinBrew);
      console.log('Damage with IronSkinBrew ' + this.damageWithIronSkinBrew);
      console.log('Hits without IronSkinBrew ' + this.hitsWithoutIronSkinBrew);
      console.log('Damage without IronSkinBrew ' + this.damageWithoutIronSkinBrew);
      console.log('Stagger Dot ' + this.staggerDot);
      console.log('Total damage ' + (this.damageWithIronSkinBrew + this.damageWithoutIronSkinBrew + this.staggerDot));
    }
  }

  suggestions(when) {
    const isbUptimePercentage = this.owner.selectedCombatant.getBuffUptime(SPELLS.IRONSKIN_BREW_BUFF.id)/ this.owner.fightDuration;

    when(isbUptimePercentage).isLessThan(0.9)
      .addSuggestion((suggest, actual, recommended) => {
        return suggest(<span> Your <SpellLink id={SPELLS.IRONSKIN_BREW.id} /> uptime was {formatPercentage(isbUptimePercentage)}%, unless there are extended periods of downtime it should be near 100%.</span>)
          .icon(SPELLS.IRONSKIN_BREW.icon)
          .actual(`${formatPercentage(actual)}% uptime`)
          .recommended(`${Math.round(formatPercentage(recommended))}% or more is recommended`)
          .regular(recommended - 0.1).major(recommended - 0.2);
      });
  }

  statistic() {
    const isbUptime = this.owner.selectedCombatant.getBuffUptime(SPELLS.IRONSKIN_BREW_BUFF.id)/ this.owner.fightDuration;
    const hitsMitigatedPercent = this.hitsWithIronSkinBrew/(this.hitsWithIronSkinBrew+this.hitsWithoutIronSkinBrew);
    return (
      <StatisticBox
        icon={<SpellIcon id={SPELLS.IRONSKIN_BREW.id} />}
        value={`${formatPercentage(isbUptime)}%`}
        label='Ironskin Brew uptime'
        tooltip={`Ironskin Brew breakdown (these values are excluding staggered damage):
       
            <ul>
                <li>You were hit <b>${this.hitsWithIronSkinBrew}</b> times with your Iron Skin Brew buff (<b>${formatThousands(this.damageWithIronSkinBrew)}</b> damage).</li>
                <li>You were hit <b>${this.hitsWithoutIronSkinBrew}</b> times <b><i>without</i></b> your Iron Skin Brew buff (<b>${formatThousands(this.damageWithoutIronSkinBrew)}</b> damage).</li>
            </ul>
            <b>${formatPercentage(hitsMitigatedPercent)}%</b> of attacks were mitigated with IronSkinBrew.`}
      />
    );
  }
  statisticOrder = STATISTIC_ORDER.OPTIONAL();
}

export default IronSkinBrew;

{'fraction_non_alphanumeric': 0.1209106239460371, 'fraction_numerical': 0.005564924114671164, 'mean_word_length': 3.684834123222749, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 37, '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': '7484234', 'n_tokens_mistral': 2131, 'n_tokens_neox': 2016, 'n_words': 361}