<commit_before>import SPELLS from 'common/SPELLS';

import Analyzer from 'Parser/Core/Analyzer';
import SpellUsable from 'Parser/Core/Modules/SpellUsable';

const HOLY_WORD_REDUCERS = {
  [SPELLS.GREATER_HEAL.id]: 6000,
  [SPELLS.FLASH_HEAL.id]: 6000,
  [SPELLS.BINDING_HEAL_TALENT.id]: 3000,
  [SPELLS.RENEW.id]: 2000,
  [SPELLS.PRAYER_OF_HEALING.id]: 4000,
  [SPELLS.HOLY_WORD_SERENITY.id]: 30000,
  [SPELLS.HOLY_WORD_SANCTIFY.id]: 30000,
  [SPELLS.SMITE.id]: 4000,
};
const APOTHEOSIS_MULTIPLIER = 3;

/**
 * This module reduces the cooldowns of Holy Word spells.
 * Feel free to combine this and the Serendipity module as they both are about the same mechanic,
 * the Serindipity one is finding out the wasted reduction while this module simply reduces them.
 */
class HolyWords extends Analyzer {
  static dependencies = {
    spellUsable: SpellUsable,
  };

  reductionMultiplier = 1;
  reductionAdditions = 0;
  hasSalvation = false;

  constructor(...args) {
    super(...args);
    const hasLotN = this.selectedCombatant.hasTalent(SPELLS.LIGHT_OF_THE_NAARU_TALENT.id);
    this.hasApotheosis = this.selectedCombatant.hasTalent(SPELLS.APOTHEOSIS_TALENT.id);
    this.hasSalvation = this.selectedCombatant.hasTalent(SPELLS.HOLY_WORD_SALVATION_TALENT.id);

    this.reductionMultiplier = hasLotN ? this.reductionMultiplier + (1/3) : this.reductionMultiplier;
    if (this.selectedCombatant.hasBuff(SPELLS.HOLY_PRIEST_T20_2SET_BONUS_BUFF)) {
      this.reductionAdditions += 1000;
    }
  }

  on_byPlayer_cast(event) {
    const spellId = event.ability.guid;

    switch(spellId) {
      case SPELLS.GREATER_HEAL.id:
      case SPELLS.FLASH_HEAL.id:
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SERENITY.id, spellId);
        return;
      case SPELLS.BINDING_HEAL_TALENT.id:
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SERENITY.id, spellId);
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SANCTIFY.id, spellId);
        return;
      case SPELLS.RENEW.id:
      case SPELLS.PRAYER_OF_HEALING.id:
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SANCTIFY.id, spellId);
        return;
      case SPELLS.SMITE.id:
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_CHASTICE.id, spellId);
        return;
      default:
        break;
    }

    if(!this.hasSalvation) {
      return;
    }

    if(spellId === SPELLS.HOLY_WORD_SERENITY.id || spellId === SPELLS.HOLY_WORD_SANCTIFY.id) {
      this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SALVATION_TALENT.id, spellId);
    }
  }

  reduceHolyWordCooldown(holyWord, spellId) {
    let reduction = (HOLY_WORD_REDUCERS[spellId] + this.reductionAdditions) * this.reductionMultiplier;
    if(this.hasApotheosis) {
      const apotheosisActive = this.selectedCombatant.hasBuff(SPELLS.APOTHEOSIS_TALENT.id);
      if(apotheosisActive) {
        reduction *= APOTHEOSIS_MULTIPLIER;
      }
    }

    if (this.spellUsable.isOnCooldown(holyWord)) {
      this.spellUsable.reduceCooldown(holyWord, reduction);
    }
  }
}

export default HolyWords;
<commit_msg>return early<commit_after>import SPELLS from 'common/SPELLS';

import Analyzer from 'Parser/Core/Analyzer';
import SpellUsable from 'Parser/Core/Modules/SpellUsable';

const HOLY_WORD_REDUCERS = {
  [SPELLS.GREATER_HEAL.id]: 6000,
  [SPELLS.FLASH_HEAL.id]: 6000,
  [SPELLS.BINDING_HEAL_TALENT.id]: 3000,
  [SPELLS.RENEW.id]: 2000,
  [SPELLS.PRAYER_OF_HEALING.id]: 4000,
  [SPELLS.HOLY_WORD_SERENITY.id]: 30000,
  [SPELLS.HOLY_WORD_SANCTIFY.id]: 30000,
  [SPELLS.SMITE.id]: 4000,
};
const APOTHEOSIS_MULTIPLIER = 3;
const LIGHT_OF_THE_NAARU_MULTIPLIER_ADDITION = 1/3;

/**
 * This module reduces the cooldowns of Holy Word spells.
 * Feel free to combine this and the Serendipity module as they both are about the same mechanic,
 * the Serindipity one is finding out the wasted reduction while this module simply reduces them.
 */
class HolyWords extends Analyzer {
  static dependencies = {
    spellUsable: SpellUsable,
  };

  reductionMultiplier = 1;
  reductionAdditions = 0;
  hasSalvation = false;

  constructor(...args) {
    super(...args);
    const hasLotN = this.selectedCombatant.hasTalent(SPELLS.LIGHT_OF_THE_NAARU_TALENT.id);
    this.hasApotheosis = this.selectedCombatant.hasTalent(SPELLS.APOTHEOSIS_TALENT.id);
    this.hasSalvation = this.selectedCombatant.hasTalent(SPELLS.HOLY_WORD_SALVATION_TALENT.id);

    if(hasLotN) {
      this.reductionMultiplier += LIGHT_OF_THE_NAARU_MULTIPLIER_ADDITION;
    }
    if (this.selectedCombatant.hasBuff(SPELLS.HOLY_PRIEST_T20_2SET_BONUS_BUFF)) {
      this.reductionAdditions += 1000;
    }
  }

  on_byPlayer_cast(event) {
    const spellId = event.ability.guid;

    switch(spellId) {
      case SPELLS.GREATER_HEAL.id:
      case SPELLS.FLASH_HEAL.id:
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SERENITY.id, spellId);
        return;
      case SPELLS.BINDING_HEAL_TALENT.id:
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SERENITY.id, spellId);
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SANCTIFY.id, spellId);
        return;
      case SPELLS.RENEW.id:
      case SPELLS.PRAYER_OF_HEALING.id:
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SANCTIFY.id, spellId);
        return;
      case SPELLS.SMITE.id:
        this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_CHASTICE.id, spellId);
        return;
      default:
        break;
    }

    if(!this.hasSalvation) {
      return;
    }

    if(spellId === SPELLS.HOLY_WORD_SERENITY.id || spellId === SPELLS.HOLY_WORD_SANCTIFY.id) {
      this.reduceHolyWordCooldown(SPELLS.HOLY_WORD_SALVATION_TALENT.id, spellId);
    }
  }

  reduceHolyWordCooldown(holyWord, spellId) {
    if (!this.spellUsable.isOnCooldown(holyWord)) {
      return;
    }

    let reduction = (HOLY_WORD_REDUCERS[spellId] + this.reductionAdditions) * this.reductionMultiplier;
    if(this.hasApotheosis) {
      const apotheosisActive = this.selectedCombatant.hasBuff(SPELLS.APOTHEOSIS_TALENT.id);
      if(apotheosisActive) {
        reduction *= APOTHEOSIS_MULTIPLIER;
      }
    }

    this.spellUsable.reduceCooldown(holyWord, reduction);
  }
}

export default HolyWords;

{'fraction_non_alphanumeric': 0.10181106216348507, 'fraction_numerical': 0.015010605318975363, 'mean_word_length': 3.7928068803752932, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1082838', 'n_tokens_mistral': 2518, 'n_tokens_neox': 2393, 'n_words': 339}