<commit_before>import React from 'react';

import Analyzer from 'parser/core/Analyzer';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import { formatPercentage } from 'common/format';
import StatTracker from 'parser/shared/modules/StatTracker';
import AbilityTracker from 'parser/shared/modules/AbilityTracker';
import SCHOOLS from 'game/MAGIC_SCHOOLS';

const debug = true;

class SpellReflect extends Analyzer {
  static dependencies = {
    statTracker: StatTracker,
    abilityTracker: AbilityTracker,
  };
  
  magicDamage = 0;
  magicDamageReduced = 0;
  totalDamage = 0;

  constructor(...args) {
    super(...args);
    this.lastCast = this.owner.fight.start_time/1000;
  }

  on_toPlayer_damage(event){
    if (event.ability.type !== SCHOOLS.ids.PHYSICAL) {
      this.magicDamage += event.unmitigatedAmount || 0;
      if(this.selectedCombatant.hasBuff(SPELLS.SPELL_REFLECTION.id)){
        this.magicDamageReduced += event.unmitigatedAmount || 0;
      }
    }
  }

  on_fightend(){
    if(debug){
      console.log(`magic damage ${this.magicDamage}`);
      console.log(`magic damage with mit ${this.magicDamageReduced}`);
      console.log(`total damage ${this.totalDamage}`);
    }
  }

  get suggestionThresholds(){
    return {
      actual: this.magicDamageReduced/this.magicDamage,
      isLessThan: {
        minor: .75,
        average: .65,
        major: .55,
      },
      style: 'percentage',
    };
  }
 
  suggestions(when) {
    when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
      return suggest(
        <>
          Try to cast <SpellLink id={SPELLS.SPELL_REFLECTION.id} />  more often when magic damage is going out to take less damage.
        </>
      )
        .icon(SPELLS.SPELL_REFLECTION.icon)
        .actual(`${formatPercentage(actual)} % magic damage reduced`)
        .recommended(`${formatPercentage(recommended)} % recommended`);
    });
  }
}

export default SpellReflect;<commit_msg>Updates from Juko (have not talked to TC yet as they are asleep)<commit_after>import React from 'react';

import Analyzer from 'parser/core/Analyzer';
import SPELLS from 'common/SPELLS';
import SpellLink from 'common/SpellLink';
import { formatPercentage } from 'common/format';
import StatTracker from 'parser/shared/modules/StatTracker';
import AbilityTracker from 'parser/shared/modules/AbilityTracker';
import SCHOOLS from 'game/MAGIC_SCHOOLS';

const debug = false;

class SpellReflect extends Analyzer {
  static dependencies = {
    statTracker: StatTracker,
    abilityTracker: AbilityTracker,
  };
  
  magicDamage = 0;
  magicDamageReduced = 0;
  totalDamage = 0;

  constructor(...args) {
    super(...args);
  }

  on_toPlayer_damage(event){
    if (event.ability.type !== SCHOOLS.ids.PHYSICAL) {
      this.magicDamage += event.unmitigatedAmount || 0;
      if(this.selectedCombatant.hasBuff(SPELLS.SPELL_REFLECTION.id)){
        this.magicDamageReduced += event.unmitigatedAmount || 0;
      }
    }
  }

  on_fightend(){
    if(debug){
      console.log(`magic damage ${this.magicDamage}`);
      console.log(`magic damage with mit ${this.magicDamageReduced}`);
      console.log(`total damage ${this.totalDamage}`);
    }
  }

  get suggestionThresholds(){
    return {
      actual: this.magicDamageReduced/this.magicDamage,
      isLessThan: {
        minor: .75,
        average: .65,
        major: .55,
      },
      style: 'percentage',
    };
  }
 
  suggestions(when) {
    when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
      return suggest(
        <>
          Try to cast <SpellLink id={SPELLS.SPELL_REFLECTION.id} />  more often when magic damage is going out to take less damage.
        </>
      )
        .icon(SPELLS.SPELL_REFLECTION.icon)
        .actual(`${formatPercentage(actual)} % magic damage With Spell Reflect Up`)
        .recommended(`${formatPercentage(recommended)} % recommended`);
    });
  }
}

export default SpellReflect;
{'fraction_non_alphanumeric': 0.12306540189715427, 'fraction_numerical': 0.006490264603095357, 'mean_word_length': 3.2357293868921775, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3434176', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1271, 'n_words': 264}