Skip to content

Commit

Permalink
Clean up CastLinkNormalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Mar 22, 2024
1 parent 017f8c8 commit 63a2251
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import MAGIC_SCHOOLS, { color } from 'game/MAGIC_SCHOOLS';
import { QualitativePerformance } from 'parser/ui/QualitativePerformance';
import { ReactNode } from 'react';
import {
RENEWING_BLAZE_ACC_HEAL_BUFF_LINK,
RENEWING_BLAZE_HEAL_BUFF_LINK,
RENEWING_BLAZE_BUFFS,
RENEWING_BLAZE_HEAL,
} from '../normalizers/DefensiveCastLinkNormalizer';

type RenewingBlazeHealBuff = {
Expand Down Expand Up @@ -80,7 +80,7 @@ class RenewingBlaze extends MajorDefensiveBuff {

private recordHeal(event: HealEvent) {
const heal = this.renewingBlazeHealBuffs.find(
(buff) => GetRelatedEvent(event, RENEWING_BLAZE_HEAL_BUFF_LINK) === buff.start,
(buff) => GetRelatedEvent(event, RENEWING_BLAZE_HEAL) === buff.start,
);
if (!heal) {
console.warn('Unable to find parent buff for Major Defensive analyzer', this.spell, event);
Expand All @@ -99,7 +99,7 @@ class RenewingBlaze extends MajorDefensiveBuff {
/** Returns the related Renewing Healing buff, for our Acc buff. */
private healBuff(mit: Mitigation): RenewingBlazeHealBuff | undefined {
return this.renewingBlazeHealBuffs.find(
(buff) => GetRelatedEvent(buff.start, RENEWING_BLAZE_ACC_HEAL_BUFF_LINK) === mit.start,
(buff) => GetRelatedEvent(buff.start, RENEWING_BLAZE_BUFFS) === mit.start,
);
}

Expand All @@ -120,7 +120,7 @@ class RenewingBlaze extends MajorDefensiveBuff {

mitigationSegments(mit: Mitigation): MitigationSegment[] {
const heal = this.renewingBlazeHealBuffs.find(
(buff) => GetRelatedEvent(buff.start, RENEWING_BLAZE_ACC_HEAL_BUFF_LINK) === mit.start,
(buff) => GetRelatedEvent(buff.start, RENEWING_BLAZE_BUFFS) === mit.start,
);

return [
Expand Down Expand Up @@ -316,7 +316,7 @@ class RenewingBlaze extends MajorDefensiveBuff {
get cooldownDetailsComponent() {
return ({ analyzer, mit }: CooldownDetailsProps) => {
const heal = this.renewingBlazeHealBuffs.find(
(buff) => GetRelatedEvent(buff.start, RENEWING_BLAZE_ACC_HEAL_BUFF_LINK) === mit?.start,
(buff) => GetRelatedEvent(buff.start, RENEWING_BLAZE_BUFFS) === mit?.start,
);
return <CooldownDetails analyzer={analyzer} mit={mit} heal={heal} />;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Options } from 'parser/core/Analyzer';
import TALENTS from 'common/TALENTS/evoker';
import SPELLS from 'common/SPELLS/evoker';
import Events, { AbsorbedEvent, ApplyBuffEvent, GetRelatedEvent } from 'parser/core/Events';
import Events, { AbsorbedEvent, ApplyBuffEvent } from 'parser/core/Events';
import { SpellLink } from 'interface';
import STATISTIC_CATEGORY from 'parser/ui/STATISTIC_CATEGORY';
import { PerformanceUsageRow } from 'parser/core/SpellUsage/core';
Expand All @@ -21,7 +21,7 @@ import { ReactNode } from 'react';
import Statistic from 'parser/ui/Statistic';
import BoringValue from 'parser/ui/BoringValueText';
import { formatNumber } from 'common/format';
import { TWIN_GUARDIAN_PARTNER_BUFF_LINK } from '../normalizers/DefensiveCastLinkNormalizer';
import { getTwinGuardianPartner } from '../normalizers/DefensiveCastLinkNormalizer';

/**
* Twin Guardian is a talent that is tied to Rescue.
Expand Down Expand Up @@ -111,7 +111,7 @@ class TwinGuardian extends MajorDefensiveBuff {
/** Returns Partners Absorb data. */
private externalMitigation(mit: Mitigation): Mitigation | undefined {
return this.externalMitigationsData.find(
(buff) => GetRelatedEvent(buff.start, TWIN_GUARDIAN_PARTNER_BUFF_LINK) === mit.start,
(buff) => getTwinGuardianPartner(buff.start) === mit.start,
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,70 @@
import { EventType } from 'parser/core/Events';
import { ApplyBuffEvent, EventType, GetRelatedEvent } from 'parser/core/Events';
import TALENTS from 'common/TALENTS/evoker';
import SPELLS from 'common/SPELLS/evoker';
import EventLinkNormalizer, { EventLink } from 'parser/core/EventLinkNormalizer';
import { Options } from 'parser/core/Module';

export const OBSIDIAN_SCALES_CAST_BUFF_LINK = 'obsidianScalesCastBuffLink';
export const RENEWING_BLAZE_CAST_BUFF_LINK = 'renewingBlazeCastBuffLink';
export const RENEWING_BLAZE_ACC_HEAL_BUFF_LINK = 'renewingBlazeAccHealBuffLink';
export const RENEWING_BLAZE_HEAL_BUFF_LINK = 'renewingBlazeHealBuffLink';
export const TWIN_GUARDIAN_PARTNER_BUFF_LINK = 'twinGuardianPartnerBuffLink';
export const OBSIDIAN_SCALES = 'obsidianScales'; // links cast to buff apply
export const RENEWING_BLAZE = 'renewingBlaze'; // links cast to buff apply
export const RENEWING_BLAZE_BUFFS = 'renewingBlazeBuffs'; // links acc & heal buffs
export const RENEWING_BLAZE_HEAL = 'renewingBlazeHeal'; // links heal buff and healing
export const TWIN_GUARDIAN_PARTNER = 'twinGuardianPartner'; // links external and personal buffs

const CAST_BUFFER = 25;
/** Heal buff gets applied once you first take damage, so there is a non-zero chance it won't apply
* till very late into the acc buff */
const RENEWING_BLAZE_BUFF_BUFFER = 10_000;
/** Heal buff can get applied immediately on use, and keeps getting refreshed on damage until
* main acc buff runs out, so we set this high to make sure we catch all. */
const RENEWING_BLAZE_DURATION = 25_000;

const EVENT_LINKS: EventLink[] = [
{
linkRelation: OBSIDIAN_SCALES_CAST_BUFF_LINK,
reverseLinkRelation: OBSIDIAN_SCALES_CAST_BUFF_LINK,
linkRelation: OBSIDIAN_SCALES,
reverseLinkRelation: OBSIDIAN_SCALES,
linkingEventId: TALENTS.OBSIDIAN_SCALES_TALENT.id,
linkingEventType: [EventType.ApplyBuff, EventType.RefreshBuff],
referencedEventId: TALENTS.OBSIDIAN_SCALES_TALENT.id,
referencedEventType: EventType.Cast,
anyTarget: true,
forwardBufferMs: 10,
backwardBufferMs: 10,
forwardBufferMs: CAST_BUFFER,
backwardBufferMs: CAST_BUFFER,
},
{
linkRelation: RENEWING_BLAZE_CAST_BUFF_LINK,
reverseLinkRelation: RENEWING_BLAZE_CAST_BUFF_LINK,
linkRelation: RENEWING_BLAZE,
reverseLinkRelation: RENEWING_BLAZE,
linkingEventId: TALENTS.RENEWING_BLAZE_TALENT.id,
linkingEventType: EventType.ApplyBuff,
referencedEventId: TALENTS.RENEWING_BLAZE_TALENT.id,
referencedEventType: EventType.Cast,
anyTarget: true,
forwardBufferMs: 10,
backwardBufferMs: 10,
anyTarget: true, // TODO: Revisit in TWW - Flame shaper can share RB
forwardBufferMs: CAST_BUFFER,
backwardBufferMs: CAST_BUFFER,
},
{
linkRelation: RENEWING_BLAZE_ACC_HEAL_BUFF_LINK,
reverseLinkRelation: RENEWING_BLAZE_ACC_HEAL_BUFF_LINK,
linkRelation: RENEWING_BLAZE_BUFFS,
reverseLinkRelation: RENEWING_BLAZE_BUFFS,
linkingEventId: TALENTS.RENEWING_BLAZE_TALENT.id,
linkingEventType: EventType.ApplyBuff,
referencedEventId: SPELLS.RENEWING_BLAZE_HEAL.id,
referencedEventType: EventType.ApplyBuff,
anyTarget: true,
forwardBufferMs: 5000,
anyTarget: true, // TODO: Revisit in TWW - Flameshaper can share RB
forwardBufferMs: RENEWING_BLAZE_BUFF_BUFFER,
maximumLinks: 1,
},
{
linkRelation: RENEWING_BLAZE_HEAL_BUFF_LINK,
reverseLinkRelation: RENEWING_BLAZE_HEAL_BUFF_LINK,
linkRelation: RENEWING_BLAZE_HEAL,
reverseLinkRelation: RENEWING_BLAZE_HEAL,
linkingEventId: SPELLS.RENEWING_BLAZE_HEAL.id,
linkingEventType: EventType.ApplyBuff,
referencedEventId: SPELLS.RENEWING_BLAZE_HEAL.id,
referencedEventType: EventType.Heal,
anyTarget: true,
forwardBufferMs: 30000,
forwardBufferMs: RENEWING_BLAZE_DURATION,
},
{
linkRelation: TWIN_GUARDIAN_PARTNER_BUFF_LINK,
reverseLinkRelation: TWIN_GUARDIAN_PARTNER_BUFF_LINK,
linkRelation: TWIN_GUARDIAN_PARTNER,
reverseLinkRelation: TWIN_GUARDIAN_PARTNER,
linkingEventId: SPELLS.TWIN_GUARDIAN_SHIELD.id,
linkingEventType: EventType.ApplyBuff,
referencedEventId: SPELLS.TWIN_GUARDIAN_SHIELD.id,
Expand All @@ -72,4 +80,8 @@ class DefensiveCastLinkNormalizer extends EventLinkNormalizer {
}
}

export function getTwinGuardianPartner(event: ApplyBuffEvent): ApplyBuffEvent | undefined {
return GetRelatedEvent<ApplyBuffEvent>(event, TWIN_GUARDIAN_PARTNER);
}

export default DefensiveCastLinkNormalizer;
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { AnyEvent, EventType, HasRelatedEvent, RemoveBuffEvent } from 'parser/core/Events';
import EventsNormalizer from 'parser/core/EventsNormalizer';
import TALENTS from 'common/TALENTS/evoker';
import {
OBSIDIAN_SCALES_CAST_BUFF_LINK,
RENEWING_BLAZE_CAST_BUFF_LINK,
} from './DefensiveCastLinkNormalizer';
import { OBSIDIAN_SCALES, RENEWING_BLAZE } from './DefensiveCastLinkNormalizer';

/**
* This Normalizer fixes an issue that happen with Obsidian Scales buff events in logs.
Expand Down Expand Up @@ -35,7 +32,7 @@ class DefensiveNormalizer extends EventsNormalizer {
event.type === EventType.ApplyBuff &&
event.ability.guid === TALENTS.OBSIDIAN_SCALES_TALENT.id
) {
if (!HasRelatedEvent(event, OBSIDIAN_SCALES_CAST_BUFF_LINK)) {
if (!HasRelatedEvent(event, OBSIDIAN_SCALES)) {
continue;
}

Expand All @@ -57,7 +54,7 @@ class DefensiveNormalizer extends EventsNormalizer {
event.type === EventType.ApplyBuff &&
event.ability.guid === TALENTS.RENEWING_BLAZE_TALENT.id
) {
if (!HasRelatedEvent(event, RENEWING_BLAZE_CAST_BUFF_LINK)) {
if (!HasRelatedEvent(event, RENEWING_BLAZE)) {
continue;
}

Expand Down

0 comments on commit 63a2251

Please sign in to comment.