<commit_before>import React from 'react';

import Analyzer from 'Parser/Core/Analyzer';
import SpellLink from 'common/SpellLink';
import SpellIcon from 'common/SpellIcon';
import {formatPercentage} from 'common/format';
import Combatants from 'Parser/Core/Modules/Combatants';
import StatisticBox from 'Main/StatisticBox';

import SPELLS from 'common/SPELLS';
import Pets from 'Parser/Core/Modules/Pets';

//import DemoPets from '../WarlockCore/Pets';

const DE_DURATION = 12;
const MILLISECONDS = 1000;

class DemEmpUptimePet extends Analyzer{
  static dependencies = {
    combatants : Combatants,
    pets: Pets,
  };

  totalMainPetTime = 0;
  lastDemEmpTimestamp = null;
  demEmpCasts = 0;

  get uptime(){
    return Math.min(1.00, this.totalMainPetTime/this.owner.fightDuration);
    //Some sort of issue with timestamps. It's entirely accurate up until general demonic empowerment hits 100%. Then it overshoots slightly.
  }

  get suggestionThresholds(){
    return {
      actual: this.uptime,
      isLessThan: {
        minor: 0.95,
        average: 0.90,
        major: 0.80,
      },
      style: 'percentage',
    };
  }

  on_toPlayer_applybuff(event){
    const spellId = event.ability.guid;
    if(event.prepull && spellId === SPELLS.DEMONIC_EMPOWERMENT.id){
      this.lastDemEmpTimestamp = 0;
    }
  }

  on_byPlayer_cast(event){
    // We're making the assumption that the player has their permament pet active.
    // Which as a Demonology warlock, we really hope is a reasonable assumption.
    const spellId = event.ability.guid;
    if(spellId === SPELLS.DEMONIC_EMPOWERMENT.id){
      this.demEmpCasts += 1;
      if(this.lastDemEmpTimestamp === null){
        this.lastDemEmpTimestamp = event.timestamp;<commit_msg>Fix incorrect assumption that fight time starts at 0 in calculating demonic empowerment uptime on main warlock pet.<commit_after>import React from 'react';

import Analyzer from 'Parser/Core/Analyzer';
import SpellLink from 'common/SpellLink';
import SpellIcon from 'common/SpellIcon';
import {formatPercentage} from 'common/format';
import Combatants from 'Parser/Core/Modules/Combatants';
import StatisticBox from 'Main/StatisticBox';

import SPELLS from 'common/SPELLS';
import Pets from 'Parser/Core/Modules/Pets';


const DE_DURATION = 12;
const MILLISECONDS = 1000;

class DemEmpUptimePet extends Analyzer{
  static dependencies = {
    combatants : Combatants,
    pets: Pets,
  };

  totalMainPetTime = 0;
  lastDemEmpTimestamp = null;

  get uptime(){
    return (this.totalMainPetTime/this.owner.fightDuration);
  }

  get suggestionThresholds(){
    return {
      actual: this.uptime,
      isLessThan: {
        minor: 0.95,
        average: 0.90,
        major: 0.80,
      },
      style: 'percentage',
    };
  }

  on_toPlayer_applybuff(event){
    const spellId = event.ability.guid;
    if(event.prepull && spellId === SPELLS.DEMONIC_EMPOWERMENT.id){
      //Player may have pre-buffed their pet.
      this.lastDemEmpTimestamp = this.owner.fight.start_time;
    }
  }

  on_byPlayer_cast(event){
    // We're making the assumption that the player has their permament pet active.
    // Which as a Demonology warlock, we really hope is a reasonable assumption.
    const spellId = event.ability.guid;
    if(spellId === SPELLS.DEMONIC_EMPOWERMENT.id){
      if(this.lastDemEmpTimestamp === null){
        this.lastDemEmpTimestamp = event.timestamp;
{'fraction_non_alphanumeric': 0.10175953079178886, 'fraction_numerical': 0.012316715542521995, 'mean_word_length': 3.517880794701987, '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': '1463115', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1074, 'n_words': 285}