Skip to content

Commit

Permalink
added a bandaid
Browse files Browse the repository at this point in the history
  • Loading branch information
EliphasNUIT committed Jun 9, 2024
1 parent ee1e4b2 commit 92e18bb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
31 changes: 31 additions & 0 deletions GW2EIEvtcParser/EIData/Buffs/BuffsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,37 @@ internal BuffsContainer(CombatData combatData, ParserController operation)
BuffsBySource = currentBuffs.GroupBy(x => x.Source).ToDictionary(x => x.Key, x => (IReadOnlyList<Buff>)x.ToList());
//
_buffSourceFinder = GetBuffSourceFinder(combatData, new HashSet<long>(BuffsByClassification[BuffClassification.Boon].Select(x => x.ID)));
// Band aid for the stack type 0 situation
if (combatData.HasStackIDs)
{
var stackType0Buffs = currentBuffs.Where(x => x.StackType == BuffStackType.StackingConditionalLoss).ToList();
foreach (Buff buff in stackType0Buffs)
{
IReadOnlyList<AbstractBuffEvent> buffData = combatData.GetBuffData(buff.ID);
var buffDataByDst = buffData.GroupBy(x => x.To).ToDictionary(x => x.Key, x => x.ToList());
foreach (KeyValuePair<AgentItem, List<AbstractBuffEvent>> pair in buffDataByDst)
{
var appliesPerInstanceID = pair.Value.OfType<BuffApplyEvent>().GroupBy(x => x.BuffInstance).ToDictionary(x => x.Key, x => x.ToList());
var removeSinglesPerInstanceID = pair.Value.OfType<BuffRemoveSingleEvent>().Where(x => !x.OverstackOrNaturalEnd).GroupBy(x => x.BuffInstance).ToDictionary(x => x.Key, x => x.ToList());
foreach (KeyValuePair<uint, List<BuffRemoveSingleEvent>> removePair in removeSinglesPerInstanceID)
{
if (appliesPerInstanceID.TryGetValue(removePair.Key, out List<BuffApplyEvent> applyList))
{
foreach (BuffRemoveSingleEvent remove in removePair.Value)
{
BuffApplyEvent apply = applyList.LastOrDefault(x => x.Time <= remove.Time);
if (apply != null && apply.OriginalAppliedDuration == remove.RemovedDuration)
{
int activeTime = apply.OriginalAppliedDuration - apply.AppliedDuration;
int elapsedTime = (int)(remove.Time - apply.Time);
remove.OverrideRemovedDuration(remove.RemovedDuration - activeTime - elapsedTime);
}
}
}
}
}
}
}
}

public bool TryGetBuffByName(string name, out Buff buff)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using static GW2EIEvtcParser.ArcDPSEnums;
using System;
using static GW2EIEvtcParser.ArcDPSEnums;

namespace GW2EIEvtcParser.ParsedData
{
public abstract class AbstractBuffRemoveEvent : AbstractBuffEvent
{
public int RemovedDuration { get; }
public int RemovedDuration { get; private set; }

internal AbstractBuffRemoveEvent(CombatItem evtcItem, AgentData agentData, SkillData skillData) : base(evtcItem, skillData)
{
Expand All @@ -20,6 +21,11 @@ internal AbstractBuffRemoveEvent(AgentItem by, AgentItem to, long time, int remo
To = to;
}

internal void OverrideRemovedDuration(int removedDuration)
{
RemovedDuration = Math.Max(removedDuration, 0);
}

internal override void TryFindSrc(ParsedEvtcLog log)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class BuffRemoveSingleEvent : AbstractBuffRemoveEvent
public uint BuffInstance { get; protected set; }

private readonly bool _byShouldntBeUnknown;
private bool _overstackOrNaturalEnd => (IFF == IFF.Unknown && CreditedBy == ParserHelper._unknownAgent && !_byShouldntBeUnknown);
internal bool OverstackOrNaturalEnd => (IFF == IFF.Unknown && CreditedBy == ParserHelper._unknownAgent && !_byShouldntBeUnknown);

internal BuffRemoveSingleEvent(CombatItem evtcItem, AgentData agentData, SkillData skillData) : base(evtcItem, agentData, skillData)
{
Expand All @@ -35,7 +35,7 @@ internal override bool IsBuffSimulatorCompliant(bool useBuffInstanceSimulator)
return true;
}
// overstack or natural end removals
return !_overstackOrNaturalEnd;
return !OverstackOrNaturalEnd;
}

internal override void UpdateSimulator(AbstractBuffSimulator simulator)
Expand Down

0 comments on commit 92e18bb

Please sign in to comment.