<commit_before>import React from 'react';

import SPELLS from 'common/SPELLS';
import ITEMS from 'common/ITEMS';
import PETS from 'common/PETS';
import SpellLink from 'common/SpellLink';
import Combatants from 'Parser/Core/Modules/Combatants';
import CorePets from 'Parser/Core/Modules/Pets';
import Analyzer from 'Parser/Core/Analyzer';

import CHI_SPENDERS from 'Parser/Monk/Windwalker/Constants';

class TheEmperorsCapacitor extends Analyzer {
  static dependencies = {
      combatants: Combatants,
      pets: CorePets,
  };
  totalStacks = 0;
  currentStacks = 0;
  stacksUsed = 0;
  stacksWasted = 0;
  cjlCasts = 0;
  averageStacksUsed = 0;
  damage = 0;
  chiSpenders = CHI_SPENDERS;

  on_initialized() {
    this.active = this.combatants.selected.hasChest(ITEMS.THE_EMPERORS_CAPACITOR.id);
  }

  on_byPlayer_applybuff(event) {
    const spellId = event.ability.guid;
    // First stack of the buff
    if (SPELLS.THE_EMPERORS_CAPACITOR_STACK.id === spellId) {
      this.totalStacks += 1;
      this.currentStacks += 1;
    }
  }

  on_byPlayer_applybuffstack(event) {
    const spellId = event.ability.guid;
    // You can only ever apply 1 stack at a time
    if (SPELLS.THE_EMPERORS_CAPACITOR_STACK.id === spellId) {
      this.totalStacks += 1;     
      this.currentStacks += 1;
     }
   }
  
  on_byPlayer_cast(event) {
    const spellId = event.ability.guid;
    if (this.chiSpenders.includes(spellId) && this.currentStacks === 20) {
      this.stacksWasted += 1;
    }

    if (SPELLS.CRACKLING_JADE_LIGHTNING.id === spellId) {
      this.stacksUsed += this.currentStacks;
      this.currentStacks = 0;
      this.cjlCasts += 1;
      this.averageStacksUsed = this.stacksUsed / this.cjlCasts;
    }
  }

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

    if (spellId === SPELLS.CRACKLING_JADE_LIGHTNING.id) {
      this.damage += event.amount + (event.absorbed || 0);
    }
  }

  _isPermanentPet(guid) {
      return Object.keys(PETS).map(key => PETS[key]).every(pet => pet.id !== guid);
  }

  on_byPlayerPet_damage(event) {
      const pet = this.pets.getSourceEntity(event);
      const spellId = event.ability.guid;
      if (!this._isPermanentPet(pet.guid)) {
         return;
      }
      if (spellId === SPELLS.CRACKLING_JADE_LIGHTNING.id) {
          this.damage += event.amount + (event.absorbed || 0);
      }
  }
<commit_msg>[Windwalker] Realized some pet ID checks were redundant<commit_after>import React from 'react';

import SPELLS from 'common/SPELLS';
import ITEMS from 'common/ITEMS';
import PETS from 'common/PETS';
import SpellLink from 'common/SpellLink';
import Combatants from 'Parser/Core/Modules/Combatants';
import CorePets from 'Parser/Core/Modules/Pets';
import Analyzer from 'Parser/Core/Analyzer';

import CHI_SPENDERS from 'Parser/Monk/Windwalker/Constants';

class TheEmperorsCapacitor extends Analyzer {
  static dependencies = {
      combatants: Combatants,
      pets: CorePets,
  };
  totalStacks = 0;
  currentStacks = 0;
  stacksUsed = 0;
  stacksWasted = 0;
  cjlCasts = 0;
  averageStacksUsed = 0;
  damage = 0;
  chiSpenders = CHI_SPENDERS;

  on_initialized() {
    this.active = this.combatants.selected.hasChest(ITEMS.THE_EMPERORS_CAPACITOR.id);
  }

  on_byPlayer_applybuff(event) {
    const spellId = event.ability.guid;
    // First stack of the buff
    if (SPELLS.THE_EMPERORS_CAPACITOR_STACK.id === spellId) {
      this.totalStacks += 1;
      this.currentStacks += 1;
    }
  }

  on_byPlayer_applybuffstack(event) {
    const spellId = event.ability.guid;
    // You can only ever apply 1 stack at a time
    if (SPELLS.THE_EMPERORS_CAPACITOR_STACK.id === spellId) {
      this.totalStacks += 1;     
      this.currentStacks += 1;
     }
   }
  
  on_byPlayer_cast(event) {
    const spellId = event.ability.guid;
    if (this.chiSpenders.includes(spellId) && this.currentStacks === 20) {
      this.stacksWasted += 1;
    }

    if (SPELLS.CRACKLING_JADE_LIGHTNING.id === spellId) {
      this.stacksUsed += this.currentStacks;
      this.currentStacks = 0;
      this.cjlCasts += 1;
      this.averageStacksUsed = this.stacksUsed / this.cjlCasts;
    }
  }

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

    if (spellId === SPELLS.CRACKLING_JADE_LIGHTNING.id) {
      this.damage += event.amount + (event.absorbed || 0);
    }
  }

  on_byPlayerPet_damage(event) {
      const spellId = event.ability.guid;
      if (spellId === SPELLS.CRACKLING_JADE_LIGHTNING.id) {
          this.damage += event.amount + (event.absorbed || 0);
      }
  }

{'fraction_non_alphanumeric': 0.1172097091624754, 'fraction_numerical': 0.008309643560026241, 'mean_word_length': 3.1657559198542806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6720046', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1660, 'n_words': 311}