<commit_before>import React from 'react';

import Analyzer from 'Parser/Core/Analyzer';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import { formatPercentage } from 'common/format';

import StatisticBox from 'Main/StatisticBox';

import Garothi from 'Raids/AntorusTheBurningThrone/GarothiWorldbreaker';
import Felhounds from 'Raids/AntorusTheBurningThrone/FelhoundsOfSargeras';
import Council from 'Raids/AntorusTheBurningThrone/AntoranHighCommand';
import Eonar from 'Raids/AntorusTheBurningThrone/EonarLifebinder';
import PKeeper from 'Raids/AntorusTheBurningThrone/PortalKeeperHasabel';
import Imonar from 'Raids/AntorusTheBurningThrone/ImonarTheSoulhunter';
import KG from 'Raids/AntorusTheBurningThrone/Kingaroth';
import Vari from 'Raids/AntorusTheBurningThrone/Varimathras';
import Coven from 'Raids/AntorusTheBurningThrone/TheCovenOfShivarra';
import Agg from 'Raids/AntorusTheBurningThrone/Aggramar';
import Argus from 'Raids/AntorusTheBurningThrone/ArgusTheUnmaker';

const mitigationBuffs = {'Paladin' : [SPELLS.SHIELD_OF_THE_RIGHTEOUS_BUFF.id,
                                      SPELLS.ARDENT_DEFENDER.id,
                                      SPELLS.GUARDIAN_OF_ANCIENT_KINGS.id]};

const mitigationChecks = new Map([
  [Garothi.id, Object.values(Garothi.fight.softMitigationChecks)],
  [Felhounds.id, Object.values(Felhounds.fight.softMitigationChecks)],
  [Council.id, Object.values(Council.fight.softMitigationChecks)],
  [Eonar.id, Object.values(Eonar.fight.softMitigationChecks)],
  [PKeeper.id, Object.values(PKeeper.fight.softMitigationChecks)],
  [Imonar.id, Object.values(Imonar.fight.softMitigationChecks)],
  [KG.id, Object.values(KG.fight.softMitigationChecks)],
  [Vari.id, Object.values(Vari.fight.softMitigationChecks)],
  [Coven.id, Object.values(Coven.fight.softMitigationChecks)],
  [Agg.id, Object.values(Agg.fight.softMitigationChecks)],
  [Argus.id, Object.values(Argus.fight.softMitigationChecks)],
]);


class MitigationCheck extends Analyzer{
  static checks;
  static buffCheck;
  static checksPassed = 0;
  static checksFailed = 0;


  constructor(...args) {
    super(...args);
    const boss = this.owner.boss;
    this.checks = mitigationChecks.get(boss.id);
    if(typeof this.checks === "undefined"){
      this.checks = [];
    }
    this.buffCheck = mitigationBuffs[this.owner.player.type];
    this.checksPassed = 0;
    this.checksFailed = 0;
  }


  on_toPlayer_damage(event){
    if(this.checks.includes(event.ability.guid)){
      if(this.buffCheck.some((e) => this.selectedCombatant.hasBuff(e))){
        this.checksPassed += 1;
      } else {
        this.checksFailed += 1;
      }
    }
  }


  statistic(){
    if(this.checksPassed + this.checksFailed === 0){
      return null;
    }
    return (
      <StatisticBox icon={<SpellIcon id={this.buffCheck[0]} />}
        value={`${formatPercentage(this.checksPassed/(this.checksPassed+this.checksFailed))} %`}
        label={`Soft mitigation checks passed.`}
        tooltip={`${this.checksPassed}/${this.checksPassed+this.checksFailed} of tank-targeted abilities were mitigated.`} />
    );
  }

}


export default MitigationCheck;
<commit_msg>Change to get boss info via findByBossId rather than having to add each boss to MitigationCheck manually.<commit_after>import React from 'react';

import Analyzer from 'Parser/Core/Analyzer';
import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import { formatPercentage } from 'common/format';

import StatisticBox from 'Main/StatisticBox';

import {findByBossId} from 'Raids';

const mitigationBuffs = {'Paladin' : [SPELLS.SHIELD_OF_THE_RIGHTEOUS_BUFF.id,
                                      SPELLS.ARDENT_DEFENDER.id,
                                      SPELLS.GUARDIAN_OF_ANCIENT_KINGS.id]};


class MitigationCheck extends Analyzer{

  static checks;
  static buffCheck;
  static checksPassed;
  static checksFailed;


  constructor(...args) {
    super(...args);
    this.checksPassed = 0;
    this.checksFailed = 0;
    const boss = findByBossId(this.owner.boss.id);
    if(boss !== null && boss.fight.hasOwnProperty('softMitigationChecks')){
      this.checks = Object.values(boss.fight.softMitigationChecks);
      if(typeof this.checks === "undefined"){
        this.checks = [];
      }
      this.buffCheck = mitigationBuffs[this.owner.player.type];
    }else{
      this.checks = [];
      this.buffCheck = [];
    }

  }


  on_toPlayer_damage(event){
    if(this.checks.includes(event.ability.guid)){
      if(this.buffCheck.some((e) => this.selectedCombatant.hasBuff(e))){
        this.checksPassed += 1;
      } else {
        this.checksFailed += 1;
      }
    }
  }


  statistic(){
    if(this.checksPassed + this.checksFailed === 0){
      return null;
    }
    return (
      <StatisticBox icon={<SpellIcon id={this.buffCheck[0]} />}
        value={`${formatPercentage(this.checksPassed/(this.checksPassed+this.checksFailed))} %`}
        label={`Soft mitigation checks passed.`}
        tooltip={`${this.checksPassed}/${this.checksPassed+this.checksFailed} of tank-targeted abilities were mitigated.`} />
    );
  }

}


export default MitigationCheck;

{'fraction_non_alphanumeric': 0.1255294570658452, 'fraction_numerical': 0.0026954177897574125, 'mean_word_length': 3.7573260073260073, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '532517', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1712, 'n_words': 282}