<commit_before>import React from 'react';
import ItemLink from 'common/ItemLink';
import SpellLink from 'common/SpellLink';
import Analyzer from 'Parser/Core/Analyzer';
import ITEMS from 'common/ITEMS';
import SPELLS from 'common/SPELLS';
import Combatants from 'Parser/Core/Modules/Combatants';
import Wrapper from 'common/Wrapper';

class TheEmeraldDreamcatcher extends Analyzer {
  static dependencies = {
    combatants: Combatants,
  };

  dreamcatcherBuffDropped = 0;
  totalCasts = 0;
  discounts = 0;

  isEDBuff(event) {
    const spellId = event.ability.guid;
    return spellId === SPELLS.THE_EMERALD_DREAMCATCHER.id;
  }

  on_initialized() {
    this.active = this.combatants.selected.hasHead(ITEMS.THE_EMERALD_DREAMCATCHER.id);
  }

  on_toPlayer_removebuff(event) {
    if (event.ability.guid === SPELLS.THE_EMERALD_DREAMCATCHER.id) {
      this.dreamcatcherBuffDropped++;
    }
  }
  on_byPlayer_cast(event) {
    if (event.ability.guid !== SPELLS.STARSURGE_MOONKIN.id){
      return;
    } 
    this.totalCasts++;
    const buff = this.combatants.selected.getBuff(SPELLS.THE_EMERALD_DREAMCATCHER.id);
    if (buff){
      this.discounts += buff.stacks;
    }
  }

  get buffDropped(){
    return this.dreamcatcherBuffDropped;
  }

  get buffDropsPerMinute(){
    return this.dreamcatcherBuffDropped / this.owner.fightDuration * 1000 * 60;
  }

  get averageDiscount(){
    return this.discounts / this.totalCasts * 5;
  }

  get suggestionThresholds() {
    return {
      actual: this.buffDropsPerMinute,
      isGreaterThan: {
        minor: 0,
        average: 1,
        major: 2,
      },
      style: 'number',
    };
  }
  
  suggestions(when) {
    when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
      return suggest(<Wrapper>You dropped the <ItemLink id={ITEMS.THE_EMERALD_DREAMCATCHER.id} /> buff {actual.toFixed(2)} times per minute. Try to keep it up at all times. For more information consult <a href='http://goo.gl/mH8NVj' target='_blank' rel='noopener noreferrer'>the guide on ED usage</a>.</Wrapper>)
        .icon(ITEMS.THE_EMERALD_DREAMCATCHER.icon)
        .actual(`${actual.toFixed(2)} buffs dropped times per minute`)
        .recommended(`${recommended} is recommended`);
    });
  }

  item() {
    return {
      item: ITEMS.THE_EMERALD_DREAMCATCHER,
      result: (
        <dfn
          data-tip={`
            You dropped the buff ${this.buffDropped} times in total.
          `}
        >
          <Wrapper>Reduced the cost of <SpellLink id={SPELLS.STARSURGE_MOONKIN.id}/> by an average of {this.averageDiscount.toFixed(2)}.</Wrapper>
        </dfn>
      ),
    };
  }

}

export default TheEmeraldDreamcatcher;<commit_msg>Grammar<commit_after>import React from 'react';
import ItemLink from 'common/ItemLink';
import SpellLink from 'common/SpellLink';
import Analyzer from 'Parser/Core/Analyzer';
import ITEMS from 'common/ITEMS';
import SPELLS from 'common/SPELLS';
import Combatants from 'Parser/Core/Modules/Combatants';
import Wrapper from 'common/Wrapper';

class TheEmeraldDreamcatcher extends Analyzer {
  static dependencies = {
    combatants: Combatants,
  };

  dreamcatcherBuffDropped = 0;
  totalCasts = 0;
  discounts = 0;

  isEDBuff(event) {
    const spellId = event.ability.guid;
    return spellId === SPELLS.THE_EMERALD_DREAMCATCHER.id;
  }

  on_initialized() {
    this.active = this.combatants.selected.hasHead(ITEMS.THE_EMERALD_DREAMCATCHER.id);
  }

  on_toPlayer_removebuff(event) {
    if (event.ability.guid === SPELLS.THE_EMERALD_DREAMCATCHER.id) {
      this.dreamcatcherBuffDropped++;
    }
  }
  on_byPlayer_cast(event) {
    if (event.ability.guid !== SPELLS.STARSURGE_MOONKIN.id){
      return;
    } 
    this.totalCasts++;
    const buff = this.combatants.selected.getBuff(SPELLS.THE_EMERALD_DREAMCATCHER.id);
    if (buff){
      this.discounts += buff.stacks;
    }
  }

  get buffDropped(){
    return this.dreamcatcherBuffDropped;
  }

  get buffDropsPerMinute(){
    return this.dreamcatcherBuffDropped / this.owner.fightDuration * 1000 * 60;
  }

  get averageDiscount(){
    return this.discounts / this.totalCasts * 5;
  }

  get suggestionThresholds() {
    return {
      actual: this.buffDropsPerMinute,
      isGreaterThan: {
        minor: 0,
        average: 1,
        major: 2,
      },
      style: 'number',
    };
  }
  
  suggestions(when) {
    when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
      return suggest(<Wrapper>You dropped the <ItemLink id={ITEMS.THE_EMERALD_DREAMCATCHER.id} /> buff {actual.toFixed(2)} times per minute. Try to keep it up at all times. For more information consult <a href='http://goo.gl/mH8NVj' target='_blank' rel='noopener noreferrer'>the guide on ED usage</a>.</Wrapper>)
        .icon(ITEMS.THE_EMERALD_DREAMCATCHER.icon)
        .actual(`${actual.toFixed(2)} buffs dropped per minute`)
        .recommended(`${recommended} is recommended`);
    });
  }

  item() {
    return {
      item: ITEMS.THE_EMERALD_DREAMCATCHER,
      result: (
        <dfn
          data-tip={`
            You dropped the buff ${this.buffDropped} times in total.
          `}
        >
          <Wrapper>Reduced the cost of <SpellLink id={SPELLS.STARSURGE_MOONKIN.id}/> by an average of {this.averageDiscount.toFixed(2)}.</Wrapper>
        </dfn>
      ),
    };
  }

}

export default TheEmeraldDreamcatcher;
{'fraction_non_alphanumeric': 0.11962962962962963, 'fraction_numerical': 0.006296296296296296, 'mean_word_length': 3.1933229813664594, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '6035784', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1878, 'n_words': 360}