From e32e0cb79416307db74b521d3e81c53da0b6b306 Mon Sep 17 00:00:00 2001 From: Vollmer Date: Mon, 25 Mar 2024 14:46:38 +0100 Subject: [PATCH] Make DefensiveNormalizer more generic --- .../normalizers/DefensiveNormalizer.ts | 69 ++++++++----------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/src/analysis/retail/evoker/shared/modules/normalizers/DefensiveNormalizer.ts b/src/analysis/retail/evoker/shared/modules/normalizers/DefensiveNormalizer.ts index a750fa8c1a3..c02b822bada 100644 --- a/src/analysis/retail/evoker/shared/modules/normalizers/DefensiveNormalizer.ts +++ b/src/analysis/retail/evoker/shared/modules/normalizers/DefensiveNormalizer.ts @@ -3,6 +3,12 @@ import EventsNormalizer from 'parser/core/EventsNormalizer'; import TALENTS from 'common/TALENTS/evoker'; import { OBSIDIAN_SCALES, RENEWING_BLAZE } from './DefensiveCastLinkNormalizer'; +/** ability id, CastLink */ +const DEFS_TO_NORMALIZE = new Map([ + [TALENTS.OBSIDIAN_SCALES_TALENT.id, OBSIDIAN_SCALES], + [TALENTS.RENEWING_BLAZE_TALENT.id, RENEWING_BLAZE], +]); + /** * This Normalizer fixes an issue that happen with Obsidian Scales buff events in logs. * For some reason it will random apply/remove itself during it's uptime, leaving us with a very high amount of "fake" @@ -16,7 +22,6 @@ import { OBSIDIAN_SCALES, RENEWING_BLAZE } from './DefensiveCastLinkNormalizer'; * This also happens for Renewing Blaze accumulator buff: * https://www.warcraftlogs.com/reports/wXGcj8gNYyfQrvVT/#fight=34&source=5&type=auras&pins=0%24Separate%24%23244F4B%24casts%240%240.0.0.Any%24176244533.0.0.Evoker%24true%240.0.0.Any%24false%24-374348&ability=374348&view=events */ - class DefensiveNormalizer extends EventsNormalizer { static dependencies = { ...EventsNormalizer.dependencies, @@ -24,65 +29,47 @@ class DefensiveNormalizer extends EventsNormalizer { normalize(events: AnyEvent[]): AnyEvent[] { const fixedEvents: AnyEvent[] = []; - let lastObsidianScalesBuffRemove: RemoveBuffEvent | undefined; - let lastRenewingBlazeBuffRemove: RemoveBuffEvent | undefined; + const latestBuffRemoveEvents = new Map(); for (const event of events) { - if ( - event.type === EventType.ApplyBuff && - event.ability.guid === TALENTS.OBSIDIAN_SCALES_TALENT.id - ) { - if (!HasRelatedEvent(event, OBSIDIAN_SCALES)) { - continue; - } - - if (lastObsidianScalesBuffRemove) { - fixedEvents.push(lastObsidianScalesBuffRemove); - lastObsidianScalesBuffRemove = undefined; - } + if (event.type !== EventType.ApplyBuff && event.type !== EventType.RemoveBuff) { + fixedEvents.push(event); + continue; } - if ( - event.type === EventType.RemoveBuff && - event.ability.guid === TALENTS.OBSIDIAN_SCALES_TALENT.id - ) { - lastObsidianScalesBuffRemove = event; + const spellId = event.ability.guid; + const castLink = DEFS_TO_NORMALIZE.get(spellId); + if (!castLink) { + fixedEvents.push(event); continue; } - if ( - event.type === EventType.ApplyBuff && - event.ability.guid === TALENTS.RENEWING_BLAZE_TALENT.id - ) { - if (!HasRelatedEvent(event, RENEWING_BLAZE)) { + if (event.type === EventType.ApplyBuff) { + // fake apply don't push + if (!HasRelatedEvent(event, castLink)) { continue; } - if (lastRenewingBlazeBuffRemove) { - fixedEvents.push(lastRenewingBlazeBuffRemove); - lastRenewingBlazeBuffRemove = undefined; + // on new "real" apply we push in our last removeBuffEvent + const hasStoredEnd = latestBuffRemoveEvents.get(spellId); + if (hasStoredEnd) { + fixedEvents.push(hasStoredEnd); + latestBuffRemoveEvents.delete(spellId); } + fixedEvents.push(event); + continue; } - if ( - event.type === EventType.RemoveBuff && - event.ability.guid === TALENTS.RENEWING_BLAZE_TALENT.id - ) { - lastRenewingBlazeBuffRemove = event; + if (event.type === EventType.RemoveBuff) { + // store the latests event so we only push the latests one + latestBuffRemoveEvents.set(spellId, event); continue; } - - fixedEvents.push(event); } // Make sure we push in the latests removal if it hasn't already been // think fightend, death, etc... - if (lastObsidianScalesBuffRemove) { - fixedEvents.push(lastObsidianScalesBuffRemove); - } - if (lastRenewingBlazeBuffRemove) { - fixedEvents.push(lastRenewingBlazeBuffRemove); - } + latestBuffRemoveEvents.forEach((event) => fixedEvents.push(event)); return fixedEvents; }