Guest User

Untitled

a guest
Mar 8th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2.  
  3. import SPELLS from 'common/SPELLS';
  4. import SpellLink from 'common/SpellLink';
  5. import { formatNumber } from 'common/format';
  6. import Analyzer, { SELECTED_PLAYER } from 'parser/core/Analyzer';
  7. import Events from 'parser/core/Events';
  8. import AbilityTracker from 'parser/shared/modules/AbilityTracker';
  9. import GlobalCooldown from 'parser/paladin/retribution/modules/core/GlobalCooldown';
  10. import HolyPowerTracker from 'parser/paladin/retribution/modules/holypower/HolyPowerTracker';
  11.  
  12. const CAST_BUFFER = 500;
  13.  
  14. class Crusade extends Analyzer {
  15.   static dependencies = {
  16.     abilityTracker: AbilityTracker,
  17.     globalCooldown: GlobalCooldown,
  18.     holyPowerTracker: HolyPowerTracker,
  19.   };
  20.  
  21.   constructor(...args) {
  22.     super(...args);
  23.     this.active = this.selectedCombatant.hasTalent(SPELLS.CRUSADE_TALENT.id);
  24.     if (!this.active) {
  25.       return;
  26.     }
  27.     this.addEventListener(Events.cast.by(SELECTED_PLAYER).spell(SPELLS.CRUSADE), this.onCrusadeCast);
  28.     this.addEventListener(Events.applybuffstack.by(SELECTED_PLAYER).spell(SPELLS.CRUSADE), this.onCrusadeBuffStack);
  29.   }
  30.  
  31.   crusadeCastTimestamp = 0;
  32.   badFirstGlobal = 0;
  33.   gcdBuffer = 0;
  34.  
  35.   onCrusadeCast(event) {
  36.     this.crusadeCastTimestamp = event.timestamp;
  37.     this.gcdBuffer = this.globalCooldown.getGlobalCooldownDuration(SPELLS.CRUSADE_TALENT.id);
  38.   }
  39.  
  40.   onCrusadeBuffStack(event) {
  41.     if (this.crusadeCastTimestamp && event.timestamp > (this.crusadeCastTimestamp + CAST_BUFFER + this.gcdBuffer)) {
  42.       this.badFirstGlobal++;
  43.     }
  44.     this.crusadeCastTimestamp = null;
  45.     if (this.holyPowerTracker.current < 5) {
  46.       event.meta = event.meta || {};
  47.       event.meta.isInefficientCast = true;
  48.       event.meta.inefficientCastReason = 'Make sure to have at least 3 Holy Power beofre using Crusade.';
  49.     }
  50.   }
  51.  
  52.   get badGlobalPercent() {
  53.     return this.badFirstGlobal / this.abilityTracker.getAbility(SPELLS.CRUSADE_TALENT.id).casts;
  54.   }
  55.  
  56.   get suggestionThresholds() {
  57.     return {
  58.       actual: 1 - this.badGlobalPercent,
  59.       isLessThan: {
  60.         minor: 1,
  61.         average: 0.75,
  62.         major: 0.5,
  63.       },
  64.       style: 'percentage',
  65.     };
  66.   }
  67.  
  68.   suggestions(when) {
  69.     when(this.suggestionThresholds).addSuggestion((suggest, actual) => {
  70.       return suggest(<>You want to build stacks of <SpellLink id={SPELLS.CRUSADE_TALENT.id} icon /> as quickly as possible. Make sure you are using <SpellLink id={SPELLS.TEMPLARS_VERDICT.id} icon /> or <SpellLink id={SPELLS.DIVINE_STORM.id} icon /> immediately after casting <SpellLink id={SPELLS.CRUSADE_TALENT.id} icon />.</>)
  71.         .icon(SPELLS.CRUSADE_TALENT.icon)
  72.         .actual(`${formatNumber(this.badFirstGlobal)} bad first global(s)`)
  73.         .recommended(`0 is recommended`);
  74.     });
  75.   }
  76. }
  77.  
  78. export default Crusade;
Advertisement
Add Comment
Please, Sign In to add comment