private void setBoonDistribution(ParsedLog log, List <PhaseData> phases, List <Boon> to_track) { BoonMap to_use = getBoonMap(log, to_track); long dur = log.getBossData().getAwareDuration(); int fight_duration = (int)(dur) / 1000; // Init boon presence points BoonsGraphModel boon_presence_points = new BoonsGraphModel("Number of Boons"); for (int i = 0; i <= fight_duration; i++) { boon_presence_points.getBoonChart().Add(new Point(i, 0)); } for (int i = 0; i < phases.Count; i++) { boon_distribution.Add(new BoonDistribution()); boon_presence.Add(new Dictionary <int, long>()); } var toFill = new Point[dur + 1]; var toFillPresence = new Point[dur + 1]; long death = getDeath(log, 0, dur); foreach (Boon boon in to_track) { int boonid = boon.getID(); if (to_use.TryGetValue(boonid, out var logs) && logs.Count != 0) { if (boon_distribution[0].ContainsKey(boonid)) { continue; } var simulator = boon.CreateSimulator(); simulator.simulate(logs, dur); if (death > 0 && getCastLogs(log, death + 1, fight_duration).Count > 0) { simulator.trim(death - log.getBossData().getFirstAware()); } else { simulator.trim(dur); } var simulation = simulator.getSimulationResult(); foreach (var simul in simulation) { for (int i = 0; i < phases.Count; i++) { var phase = phases[i]; var presenceDict = boon_presence[i]; if (!boon_distribution[i].TryGetValue(boonid, out var distrib)) { distrib = new Dictionary <ushort, OverAndValue>(); boon_distribution[i].Add(boonid, distrib); } Add(presenceDict, boonid, simul.getItemDuration(phase.getStart(), phase.getEnd())); foreach (ushort src in simul.getSrc()) { if (distrib.TryGetValue(src, out var toModify)) { toModify.value += simul.getDuration(src, phase.getStart(), phase.getEnd()); toModify.overstack += simul.getOverstack(src, phase.getStart(), phase.getEnd()); distrib[src] = toModify; } else { distrib.Add(src, new OverAndValue( simul.getDuration(src, phase.getStart(), phase.getEnd()), simul.getOverstack(src, phase.getStart(), phase.getEnd()))); } } } } // Graphs // full precision for (int i = 0; i <= dur; i++) { toFill[i] = new Point(i, 0); toFillPresence[i] = new Point(i, 0); } foreach (var simul in simulation) { int start = (int)simul.getStart(); int end = (int)simul.getEnd(); bool present = simul.getItemDuration() > 0; for (int i = start; i <= end; i++) { toFill[i] = new Point(i, simul.getStack(i)); toFillPresence[i] = new Point(i, present ? 1 : 0); } } // reduce precision to seconds var reducedPrecision = new List <Point>(capacity: fight_duration + 1); var boonPresence = boon_presence_points.getBoonChart(); var updateBoonPresence = Boon.getBoonList().Any(x => x.getID() == boonid); for (int i = 0; i <= fight_duration; i++) { reducedPrecision.Add(new Point(i, toFill[1000 * i].Y)); if (updateBoonPresence) { boonPresence[i] = new Point(i, boonPresence[i].Y + toFillPresence[1000 * i].Y); } } boon_points[boonid] = new BoonsGraphModel(boon.getName(), reducedPrecision); } } boon_points[-2] = boon_presence_points; }
protected void SetBoonStatus(ParsedLog log) { BoonMap toUse = GetBoonMap(log); long dur = log.FightData.FightDuration; int fightDuration = (int)(dur) / 1000; BoonsGraphModel boonPresenceGraph = new BoonsGraphModel(Boon.BoonsByIds[Boon.NumberOfBoonsID]); BoonsGraphModel condiPresenceGraph = new BoonsGraphModel(Boon.BoonsByIds[Boon.NumberOfConditionsID]); HashSet <long> boonIds = new HashSet <long>(Boon.GetBoonList().Select(x => x.ID)); HashSet <long> condiIds = new HashSet <long>(Boon.GetCondiBoonList().Select(x => x.ID)); InitBoonStatusData(log); long death = GetDeath(log, 0, dur); foreach (Boon boon in TrackedBoons) { long boonid = boon.ID; if (toUse.TryGetValue(boonid, out List <BoonLog> logs) && logs.Count != 0) { if (BoonPoints.ContainsKey(boonid)) { continue; } BoonSimulator simulator = boon.CreateSimulator(log); simulator.Simulate(logs, dur); if (death > 0 && GetCastLogs(log, death + 5000, dur).Count == 0) { simulator.Trim(death); } else { simulator.Trim(dur); } bool updateBoonPresence = boonIds.Contains(boonid); bool updateCondiPresence = condiIds.Contains(boonid); List <BoonsGraphModel.Segment> graphSegments = new List <BoonsGraphModel.Segment>(); foreach (BoonSimulationItem simul in simulator.GenerationSimulation) { SetBoonStatusGenerationData(log, simul, boonid, updateBoonPresence, updateCondiPresence); BoonsGraphModel.Segment segment = simul.ToSegment(); if (graphSegments.Count == 0) { graphSegments.Add(new BoonsGraphModel.Segment(0, segment.Start, 0)); } else if (graphSegments.Last().End != segment.Start) { graphSegments.Add(new BoonsGraphModel.Segment(graphSegments.Last().End, segment.Start, 0)); } graphSegments.Add(segment); } SetExtraBoonStatusGenerationData(log, simulator, boonid, updateCondiPresence); if (graphSegments.Count > 0) { graphSegments.Add(new BoonsGraphModel.Segment(graphSegments.Last().End, dur, 0)); } else { graphSegments.Add(new BoonsGraphModel.Segment(0, dur, 0)); } BoonPoints[boonid] = new BoonsGraphModel(boon, graphSegments); if (updateBoonPresence || updateCondiPresence) { List <BoonsGraphModel.Segment> segmentsToFill = updateBoonPresence ? boonPresenceGraph.BoonChart : condiPresenceGraph.BoonChart; bool firstPass = segmentsToFill.Count == 0; foreach (BoonsGraphModel.Segment seg in BoonPoints[boonid].BoonChart) { long start = seg.Start; long end = seg.End; int value = seg.Value > 0 ? 1 : 0; if (firstPass) { segmentsToFill.Add(new BoonsGraphModel.Segment(start, end, value)); } else { for (int i = 0; i < segmentsToFill.Count; i++) { BoonsGraphModel.Segment curSeg = segmentsToFill[i]; long curEnd = curSeg.End; long curStart = curSeg.Start; int curVal = curSeg.Value; if (curStart > end) { break; } if (curEnd < start) { continue; } if (end <= curEnd) { curSeg.End = start; segmentsToFill.Insert(i + 1, new BoonsGraphModel.Segment(start, end, curVal + value)); segmentsToFill.Insert(i + 2, new BoonsGraphModel.Segment(end, curEnd, curVal)); break; } else { curSeg.End = start; segmentsToFill.Insert(i + 1, new BoonsGraphModel.Segment(start, curEnd, curVal + value)); start = curEnd; i++; } } } } if (updateBoonPresence) { boonPresenceGraph.FuseSegments(); } else { condiPresenceGraph.FuseSegments(); } } } } BoonPoints[Boon.NumberOfBoonsID] = boonPresenceGraph; BoonPoints[Boon.NumberOfConditionsID] = condiPresenceGraph; SetExtraBoonStatusData(log); }
private void SetBoonDistribution(ParsedLog log) { List <PhaseData> phases = log.FightData.GetPhases(log); BoonMap toUse = GetBoonMap(log); long dur = log.FightData.FightDuration; int fightDuration = (int)(dur) / 1000; HashSet <long> extraDataID = new HashSet <long> { 50421, 31803 }; BoonsGraphModel boonPresenceGraph = new BoonsGraphModel("Number of Boons"); BoonsGraphModel condiPresenceGraph = new BoonsGraphModel("Number of Conditions"); HashSet <long> boonIds = new HashSet <long>(Boon.GetBoonList().Select(x => x.ID)); HashSet <long> condiIds = new HashSet <long>(Boon.GetCondiBoonList().Select(x => x.ID)); for (int i = 0; i < phases.Count; i++) { _boonDistribution.Add(new BoonDistribution()); _boonPresence.Add(new Dictionary <long, long>()); _condiPresence.Add(new Dictionary <long, long>()); _condiCleanse.Add(new Dictionary <ushort, Dictionary <long, List <long> > >()); } long death = GetDeath(log, 0, dur) - log.FightData.FightStart; foreach (Boon boon in BoonToTrack) { long boonid = boon.ID; if (toUse.TryGetValue(boonid, out var logs) && logs.Count != 0) { if (_boonDistribution[0].ContainsKey(boonid)) { continue; } bool requireExtraData = extraDataID.Contains(boonid); var simulator = boon.CreateSimulator(log); simulator.Simulate(logs, dur); if (death > 0 && GetCastLogs(log, death + 5000, dur).Count == 0) { simulator.Trim(death); } else { simulator.Trim(dur); } var updateBoonPresence = boonIds.Contains(boonid); var updateCondiPresence = boonid != 873 && condiIds.Contains(boonid); var generationSimulation = simulator.GenerationSimulationResult; var graphSegments = new List <BoonsGraphModel.Segment>(); foreach (var simul in generationSimulation.Items) { for (int i = 0; i < phases.Count; i++) { var phase = phases[i]; if (!_boonDistribution[i].TryGetValue(boonid, out var distrib)) { distrib = new Dictionary <ushort, OverAndValue>(); _boonDistribution[i].Add(boonid, distrib); } if (updateBoonPresence) { Add(_boonPresence[i], boonid, simul.GetClampedDuration(phase.Start, phase.End)); } if (updateCondiPresence) { Add(_condiPresence[i], boonid, simul.GetClampedDuration(phase.Start, phase.End)); } foreach (ushort src in simul.GetSrc()) { if (distrib.TryGetValue(src, out var toModify)) { toModify.Value += simul.GetSrcDuration(src, phase.Start, phase.End); distrib[src] = toModify; } else { distrib.Add(src, new OverAndValue( simul.GetSrcDuration(src, phase.Start, phase.End), 0)); } } } List <BoonsGraphModel.Segment> segments = simul.ToSegment(); if (segments.Count > 0) { if (graphSegments.Count == 0) { graphSegments.Add(new BoonsGraphModel.Segment(0, segments.First().Start, 0)); } else if (graphSegments.Last().End != segments.First().Start) { graphSegments.Add(new BoonsGraphModel.Segment(graphSegments.Last().End, segments.First().Start, 0)); } graphSegments.AddRange(simul.ToSegment()); } } foreach (var simul in simulator.OverstackSimulationResult) { for (int i = 0; i < phases.Count; i++) { var phase = phases[i]; if (!_boonDistribution[i].TryGetValue(boonid, out var distrib)) { distrib = new Dictionary <ushort, OverAndValue>(); _boonDistribution[i].Add(boonid, distrib); } if (distrib.TryGetValue(simul.Src, out var toModify)) { toModify.Overstack += simul.GetOverstack(phase.Start, phase.End); distrib[simul.Src] = toModify; } else { distrib.Add(simul.Src, new OverAndValue( 0, simul.GetOverstack(phase.Start, phase.End))); } } } if (updateCondiPresence) { foreach (var simul in simulator.CleanseSimulationResult) { for (int i = 0; i < phases.Count; i++) { var phase = phases[i]; long cleanse = simul.GetCleanseDuration(phase.Start, phase.End); if (cleanse > 0) { if (!_condiCleanse[i].TryGetValue(simul.ProvokedBy, out var dict)) { dict = new Dictionary <long, List <long> >(); _condiCleanse[i].Add(simul.ProvokedBy, dict); } if (!dict.TryGetValue(boonid, out var list)) { list = new List <long>(); dict.Add(boonid, list); } list.Add(cleanse); } } } } if (requireExtraData) { GenerateExtraBoonData(log, boonid, generationSimulation, phases); } if (graphSegments.Count > 0) { graphSegments.Add(new BoonsGraphModel.Segment(graphSegments.Last().End, dur, 0)); } else { graphSegments.Add(new BoonsGraphModel.Segment(0, dur, 0)); } _boonPoints[boonid] = new BoonsGraphModel(boon.Name, graphSegments); if (updateBoonPresence || updateCondiPresence) { List <BoonsGraphModel.Segment> segmentsToFill = updateBoonPresence ? boonPresenceGraph.BoonChart : condiPresenceGraph.BoonChart; bool firstPass = segmentsToFill.Count == 0; foreach (BoonsGraphModel.Segment seg in _boonPoints[boonid].BoonChart) { long start = seg.Start; long end = seg.End; int value = seg.Value > 0 ? 1 : 0; if (firstPass) { segmentsToFill.Add(new BoonsGraphModel.Segment(start, end, value)); } else { for (int i = 0; i < segmentsToFill.Count; i++) { BoonsGraphModel.Segment curSeg = segmentsToFill[i]; long curEnd = curSeg.End; long curStart = curSeg.Start; int curVal = curSeg.Value; if (curStart > end) { break; } if (curEnd < start) { continue; } if (end <= curEnd) { curSeg.End = start; segmentsToFill.Insert(i + 1, new BoonsGraphModel.Segment(start, end, curVal + value)); segmentsToFill.Insert(i + 2, new BoonsGraphModel.Segment(end, curEnd, curVal)); break; } else { curSeg.End = start; segmentsToFill.Insert(i + 1, new BoonsGraphModel.Segment(start, curEnd, curVal + value)); start = curEnd; i++; } } } } if (updateBoonPresence) { boonPresenceGraph.FuseSegments(); } else { condiPresenceGraph.FuseSegments(); } } } } _boonPoints[-2] = boonPresenceGraph; _boonPoints[-3] = condiPresenceGraph; }