Skip to content

Commit

Permalink
Make DefensiveNormalizer more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Mar 25, 2024
1 parent 26c3d23 commit e32e0cb
Showing 1 changed file with 28 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, string>([
[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"
Expand All @@ -16,73 +22,54 @@ 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,
};

normalize(events: AnyEvent[]): AnyEvent[] {
const fixedEvents: AnyEvent[] = [];
let lastObsidianScalesBuffRemove: RemoveBuffEvent | undefined;
let lastRenewingBlazeBuffRemove: RemoveBuffEvent | undefined;
const latestBuffRemoveEvents = new Map<number, RemoveBuffEvent>();

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;
}
Expand Down

0 comments on commit e32e0cb

Please sign in to comment.