<commit_before>import React from 'react';

import Icon from 'common/Icon';
import SPELLS from 'common/SPELLS';
import RESOURCE_TYPES from 'game/RESOURCE_TYPES';
import { formatDuration, formatPercentage } from 'common/format';
import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';
import Tooltip from 'common/Tooltip';
import RegenResourceCapTracker from 'parser/shared/modules/RegenResourceCapTracker';

import SpellEnergyCost from './SpellEnergyCost';

const BASE_ENERGY_REGEN = 10;
const VIGOR_REGEN_MULTIPLIER = 1.1;

const BASE_ENERGY_MAX = 100;
const VIGOR_MAX_ADDITION = 50;

const RESOURCE_REFUND_ON_MISS = 0.8;

/**
 * Sets up RegenResourceCapTracker to accurately track the regenerating energy of rogues.
 * Taking into account the effect of buffs, talents, and items on the energy cost of abilities,
 * the maximum energy amount, and the regeneration rate.
 */
class EnergyCapTracker extends RegenResourceCapTracker {
  static dependencies = {
    ...RegenResourceCapTracker.dependencies,
    // Needed for the `resourceCost` prop of events
    spellResourceCost: SpellEnergyCost,
  };

  static resourceType = RESOURCE_TYPES.ENERGY;
  static baseRegenRate = BASE_ENERGY_REGEN;
  static isRegenHasted = true;
  static cumulativeEventWindow = 400;
  static resourceRefundOnMiss = RESOURCE_REFUND_ON_MISS;
  static exemptFromRefund = [
  ];

  naturalRegenRate() {
    let regen = super.naturalRegenRate();
    if (this.selectedCombatant.hasTalent(SPELLS.VIGOR_TALENT.id)) {
      regen *= VIGOR_REGEN_MULTIPLIER;
    }
    return regen;
  }

  currentMaxResource() {
    let max = BASE_ENERGY_MAX;
    if (this.selectedCombatant.hasTalent(SPELLS.VIGOR_TALENT.id)) {
      max += VIGOR_MAX_ADDITION;
    }
    // What should be x.5 becomes x in-game.
    return Math.floor(max);
  }

  get wastedPercent() {
    return (this.missedRegen / this.naturalRegen) || 0;
  }

  get suggestionThresholds() {
    return {
      actual: 1 - this.wastedPercent,
      isLessThan: {
        minor: 0.95,
        average: 0.9,
        major: 0.8,
      },
      style: 'percentage',
    };
  }

  suggestions(when) {
    when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
      return suggest(
        <>
          You're allowing your energy to reach its cap. While at its maximum value you miss out on the energy that would have regenerated. Although it can be beneficial to let energy pool ready to be used at the right time, try to spend some before it reaches the cap.
        </>
      )
        .icon('spell_shadow_shadowworddominate')
        .actual(`${actual.toFixed(1)} regenerated energy lost per minute due to being capped.`)<commit_msg>Added Adrenaline Rush and Buried Treasure to rogue EnergyCapTracker<commit_after>import React from 'react';

import Icon from 'common/Icon';
import SPELLS from 'common/SPELLS';
import RESOURCE_TYPES from 'game/RESOURCE_TYPES';
import { formatDuration, formatPercentage } from 'common/format';
import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';
import Tooltip from 'common/Tooltip';
import RegenResourceCapTracker from 'parser/shared/modules/RegenResourceCapTracker';

import SpellEnergyCost from './SpellEnergyCost';

const BASE_ENERGY_REGEN = 10;
const BURIED_TREASURE_REGEN = 4;
const VIGOR_REGEN_MULTIPLIER = 1.1;
const ADRENALINE_RUSH_REGEN_MULTIPLIER = 1.6;

const BASE_ENERGY_MAX = 100;
const VIGOR_MAX_ADDITION = 50;
const ADRENALINE_RUSH_MAX_ADDITION = 50;

const RESOURCE_REFUND_ON_MISS = 0.8;

/**
 * Sets up RegenResourceCapTracker to accurately track the regenerating energy of rogues.
 * Taking into account the effect of buffs, talents, and items on the energy cost of abilities,
 * the maximum energy amount, and the regeneration rate.
 */
class EnergyCapTracker extends RegenResourceCapTracker {
  static dependencies = {
    ...RegenResourceCapTracker.dependencies,
    // Needed for the `resourceCost` prop of events
    spellResourceCost: SpellEnergyCost,
  };

  static resourceType = RESOURCE_TYPES.ENERGY;
  static baseRegenRate = BASE_ENERGY_REGEN;
  static isRegenHasted = true;
  static cumulativeEventWindow = 400;
  static resourceRefundOnMiss = RESOURCE_REFUND_ON_MISS;
  static exemptFromRefund = [
  ];
  static buffsChangeMax = [
    SPELLS.ADRENALINE_RUSH.id,
  ];
  static buffsChangeRegen = [
    SPELLS.ADRENALINE_RUSH.id, 
    SPELLS.BURIED_TREASURE.id,
  ];

  naturalRegenRate() {
    let regen = super.naturalRegenRate();
    if(this.combatantHasBuffActive(SPELLS.BURIED_TREASURE.id)){
      // Buried Treasure buff adds 4 energy per second, converted to ms
      regen += (BURIED_TREASURE_REGEN / 1000);
    }

    if (this.selectedCombatant.hasTalent(SPELLS.VIGOR_TALENT.id)) {
      regen *= VIGOR_REGEN_MULTIPLIER;
    }
    if(this.combatantHasBuffActive(SPELLS.ADRENALINE_RUSH.id)){
      regen *= ADRENALINE_RUSH_REGEN_MULTIPLIER;
    }

    return regen;
  }

  currentMaxResource() {
    let max = BASE_ENERGY_MAX;
    if (this.selectedCombatant.hasTalent(SPELLS.VIGOR_TALENT.id)) {
      max += VIGOR_MAX_ADDITION;
    }
    if(this.combatantHasBuffActive(SPELLS.ADRENALINE_RUSH.id)){
      max += ADRENALINE_RUSH_MAX_ADDITION;
    }
    // What should be x.5 becomes x in-game.
    return Math.floor(max);
  }

  get wastedPercent() {
    return (this.missedRegen / this.naturalRegen) || 0;
  }

  get suggestionThresholds() {
    return {
      actual: 1 - this.wastedPercent,
      isLessThan: {
        minor: 0.95,
        average: 0.9,
        major: 0.8,
      },
      style: 'percentage',
    };
  }

  suggestions(when) {
    when(this.suggestionThresholds).addSuggestion((suggest, actual, recommended) => {
      return suggest(
        <>
          You're allowing your energy to reach its cap. While at its maximum value you miss out on the energy that would have regenerated. Although it can be beneficial to let energy pool ready to be used at the right time, try to spend some before it reaches the cap.
        </>
      )
        .icon('spell_shadow_shadowworddominate')
        .actual(`${actual.toFixed(1)} regenerated energy lost per minute due to being capped.`)
{'fraction_non_alphanumeric': 0.0885932175888366, 'fraction_numerical': 0.00973551841635567, 'mean_word_length': 3.7017543859649122, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4735763', 'n_tokens_mistral': 2113, 'n_tokens_neox': 1980, 'n_words': 514}