<commit_before>import React from 'react';
import Icon from 'common/Icon';
import StatisticBox, { STATISTIC_ORDER } from 'Main/StatisticBox';
import { formatNumber } from 'common/format';
import Module from 'Parser/Core/Module';
import SPELLS from 'common/SPELLS';
import ResourceTypes from 'common/RESOURCE_TYPES';

class AstralPower extends Module {
  lastAstral = 0;
  aspWasted = 0;

  on_toPlayer_energize(event) {
    for (let i = 0; i < event.classResources.length; i += 1) {
      if (event.classResources[i].type === ResourceTypes.ASTRAL_POWER) {
        const maxAsP = event.classResources[i].max;
        const addedAsP = event.resourceChange * 10;

        if (this.lastAstral + addedAsP > maxAsP) {
          this.aspWasted += this.lastAstral + addedAsP - maxAsP;
        }

        this.lastAstral = event.classResources[i].amount;
      }
    }
  }

  on_byPlayer_cast(event) {
    const spellId = event.ability.guid;
    if (SPELLS.STARSURGE_MOONKIN.id !== spellId && SPELLS.STARFALL.id !== spellId && SPELLS.STARFALL_CAST.id !== spellId) {
      return;
    }
      
    for (let i = 0; i < event.classResources.length; i += 1) {
      if (event.classResources[i].type === ResourceTypes.ASTRAL_POWER) {
        if (event.classResources[i].cost) {
          this.lastAstral = this.lastAstral - (event.classResources[i].cost);
        }
      }
    }
  }

  suggestions(when) {
    const wastedPerMin = ((this.aspWasted) / (this.owner.fightDuration / 100)) * 60;
    when(wastedPerMin).isGreaterThan(0)
        .addSuggestion((suggest, actual, recommended) => {
          return suggest(<span>You overcapped {this.aspWasted / 10} Astral Power. Always prioritize spending it over avoiding the overcap or any other ability.</span>)
            .icon('ability_druid_cresentburn')
            .actual(`${formatNumber(actual)} overcapped Astral Power per minute`)
            .recommended('0 overcapped Astral Power is recommended.')
            .regular(recommended + 4).major(recommended + 8);
        });
  }
  
  statistic() {
    return (
        <StatisticBox
            icon={<Icon icon='ability_druid_cresentburn' />}
            value={`${this.aspWasted / 10}`}
            label='Overcapped AsP'
            tooltip={`Astral Power overcapping is often due to missmanagement of resources, but can also be due to an overwhelming amount of OI procs.`}
        />
    );
  }
  statisticOrder = STATISTIC_ORDER.CORE(7);
}

export default AstralPower;<commit_msg>Fix typo<commit_after>import React from 'react';
import Icon from 'common/Icon';
import StatisticBox, { STATISTIC_ORDER } from 'Main/StatisticBox';
import { formatNumber } from 'common/format';
import Module from 'Parser/Core/Module';
import SPELLS from 'common/SPELLS';
import ResourceTypes from 'common/RESOURCE_TYPES';

class AstralPower extends Module {
  lastAstral = 0;
  aspWasted = 0;

  on_toPlayer_energize(event) {
    for (let i = 0; i < event.classResources.length; i += 1) {
      if (event.classResources[i].type === ResourceTypes.ASTRAL_POWER) {
        const maxAsP = event.classResources[i].max;
        const addedAsP = event.resourceChange * 10;

        if (this.lastAstral + addedAsP > maxAsP) {
          this.aspWasted += this.lastAstral + addedAsP - maxAsP;
        }

        this.lastAstral = event.classResources[i].amount;
      }
    }
  }

  on_byPlayer_cast(event) {
    const spellId = event.ability.guid;
    if (SPELLS.STARSURGE_MOONKIN.id !== spellId && SPELLS.STARFALL.id !== spellId && SPELLS.STARFALL_CAST.id !== spellId) {
      return;
    }
      
    for (let i = 0; i < event.classResources.length; i += 1) {
      if (event.classResources[i].type === ResourceTypes.ASTRAL_POWER) {
        if (event.classResources[i].cost) {
          this.lastAstral = this.lastAstral - (event.classResources[i].cost);
        }
      }
    }
  }

  suggestions(when) {
    const wastedPerMin = ((this.aspWasted) / (this.owner.fightDuration / 100)) * 60;
    when(wastedPerMin).isGreaterThan(0)
        .addSuggestion((suggest, actual, recommended) => {
          return suggest(<span>You overcapped {this.aspWasted / 10} Astral Power. Always prioritize spending it over avoiding the overcap or any other ability.</span>)
            .icon('ability_druid_cresentburn')
            .actual(`${formatNumber(actual)} overcapped Astral Power per minute`)
            .recommended('0 overcapped Astral Power is recommended.')
            .regular(recommended + 4).major(recommended + 8);
        });
  }
  
  statistic() {
    return (
        <StatisticBox
            icon={<Icon icon='ability_druid_cresentburn' />}
            value={`${this.aspWasted / 10}`}
            label='Overcapped AsP'
            tooltip={`Astral Power overcapping is often due to mismanagement of resources, but can also be due to an overwhelming amount of OI procs.`}
        />
    );
  }
  statisticOrder = STATISTIC_ORDER.CORE(7);
}

export default AstralPower;
{'fraction_non_alphanumeric': 0.12085691188358932, 'fraction_numerical': 0.00889248181083266, 'mean_word_length': 2.86640625, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '369692', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1580, 'n_words': 352}