diff --git a/src/StatisticsAnalysisTool/Common/ExtensionMethod.cs b/src/StatisticsAnalysisTool/Common/ExtensionMethod.cs index 31e86c0e..78b89859 100644 --- a/src/StatisticsAnalysisTool/Common/ExtensionMethod.cs +++ b/src/StatisticsAnalysisTool/Common/ExtensionMethod.cs @@ -261,6 +261,12 @@ public static long GetCurrentTotalHeal(this List x.Value.Heal); } + public static long GetCurrentTotalTakenDamage(this List> playerObjects) + { + return playerObjects.Count <= 0 ? 0 : playerObjects.Max(x => x.Value.TakenDamage); + } + + public static double GetDamagePercentage(this List> playerObjects, double playerDamage) { var totalDamage = playerObjects.Sum(x => x.Value.Damage); @@ -273,6 +279,12 @@ public static double GetHealPercentage(this List> playerObjects, double playerDamage) + { + var totalTakenDamage = playerObjects.Sum(x => x.Value.TakenDamage); + return 100.00 / totalTakenDamage * playerDamage; + } + #endregion #region DateTime diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs index e96b48e4..3cf988d3 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs @@ -61,6 +61,11 @@ public DamageMeterBindings() Name = TranslationSortByHps, DamageMeterSortType = DamageMeterSortType.Hps }; + var takenDamageStruct = new DamageMeterSortStruct + { + Name = TranslationTakenDamage, + DamageMeterSortType = DamageMeterSortType.TakenDamage + }; DamageMeterSort.Clear(); DamageMeterSort.Add(sortByDamageStruct); @@ -68,6 +73,7 @@ public DamageMeterBindings() DamageMeterSort.Add(sortByNameStruct); DamageMeterSort.Add(sortByHealStruct); DamageMeterSort.Add(sortByHpsStruct); + DamageMeterSort.Add(takenDamageStruct); DamageMeterSortSelection = sortByDamageStruct; DamageMeterSnapshotSort.Clear(); @@ -76,6 +82,7 @@ public DamageMeterBindings() DamageMeterSnapshotSort.Add(sortByNameStruct); DamageMeterSnapshotSort.Add(sortByHealStruct); DamageMeterSnapshotSort.Add(sortByHpsStruct); + DamageMeterSnapshotSort.Add(takenDamageStruct); DamageMeterSnapshotSortSelection = sortByDamageStruct; IsSnapshotAfterMapChangeActive = SettingsController.CurrentSettings.IsSnapshotAfterMapChangeActive; @@ -159,33 +166,37 @@ public void SetDamageMeterSort() switch (DamageMeterSortSelection.DamageMeterSortType) { case DamageMeterSortType.Damage: - SetIsDamageMeterShowing(DamageMeter, true); + SetIsDamageMeterShowing(DamageMeter, DamageMeterStyleFragmentType.Damage); DamageMeter.OrderByReference(DamageMeter.OrderByDescending(x => x.DamageInPercent).ToList()); return; case DamageMeterSortType.Dps: - SetIsDamageMeterShowing(DamageMeter, true); + SetIsDamageMeterShowing(DamageMeter, DamageMeterStyleFragmentType.Damage); DamageMeter.OrderByReference(DamageMeter.OrderByDescending(x => x.Dps).ToList()); return; case DamageMeterSortType.Name: - SetIsDamageMeterShowing(DamageMeter, true); + SetIsDamageMeterShowing(DamageMeter, DamageMeterStyleFragmentType.Damage); DamageMeter.OrderByReference(DamageMeter.OrderBy(x => x.Name).ToList()); return; case DamageMeterSortType.Heal: - SetIsDamageMeterShowing(DamageMeter, false); + SetIsDamageMeterShowing(DamageMeter, DamageMeterStyleFragmentType.Heal); DamageMeter.OrderByReference(DamageMeter.OrderByDescending(x => x.HealInPercent).ToList()); return; case DamageMeterSortType.Hps: - SetIsDamageMeterShowing(DamageMeter, false); + SetIsDamageMeterShowing(DamageMeter, DamageMeterStyleFragmentType.Heal); DamageMeter.OrderByReference(DamageMeter.OrderByDescending(x => x.Hps).ToList()); break; + case DamageMeterSortType.TakenDamage: + SetIsDamageMeterShowing(DamageMeter, DamageMeterStyleFragmentType.TakenDamage); + DamageMeter.OrderByReference(DamageMeter.OrderByDescending(x => x.TakenDamage).ToList()); + return; } } - private static void SetIsDamageMeterShowing(IEnumerable damageMeter, bool isDamageMeterShowing) + private static void SetIsDamageMeterShowing(IEnumerable damageMeter, DamageMeterStyleFragmentType damageMeterStyleFragmentType) { foreach (var fragment in damageMeter) { - fragment.IsDamageMeterShowing = isDamageMeterShowing; + fragment.DamageMeterStyleFragmentType = damageMeterStyleFragmentType; } } @@ -340,48 +351,55 @@ public void SetDamageMeterSnapshotSort() switch (DamageMeterSnapshotSortSelection.DamageMeterSortType) { case DamageMeterSortType.Damage: - SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, true); + SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Damage); if (DamageMeterSnapshotSelection != null) { DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.DamageInPercent).ToList(); } return; case DamageMeterSortType.Dps: - SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, true); + SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Damage); if (DamageMeterSnapshotSelection != null) { DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.Dps).ToList(); } return; case DamageMeterSortType.Name: - SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, true); + SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Damage); if (DamageMeterSnapshotSelection != null) { DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderBy(x => x.Name).ToList(); } return; case DamageMeterSortType.Heal: - SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, false); + SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Heal); if (DamageMeterSnapshotSelection != null) { DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.HealInPercent).ToList(); } return; case DamageMeterSortType.Hps: - SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, false); + SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.Heal); if (DamageMeterSnapshotSelection != null) { DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.Hps).ToList(); } break; + case DamageMeterSortType.TakenDamage: + SetIsDamageMeterSnapshotShowing(DamageMeterSnapshotSelection?.DamageMeter, DamageMeterStyleFragmentType.TakenDamage); + if (DamageMeterSnapshotSelection != null) + { + DamageMeterSnapshotSelection.DamageMeter = DamageMeterSnapshotSelection?.DamageMeter?.OrderByDescending(x => x.TakenDamage).ToList(); + } + break; } } - - private static void SetIsDamageMeterSnapshotShowing(IEnumerable damageMeter, bool isDamageMeterShowing) + + private static void SetIsDamageMeterSnapshotShowing(IEnumerable damageMeter, DamageMeterStyleFragmentType damageMeterStyleFragmentType) { foreach (var fragment in damageMeter ?? new List()) { - fragment.IsDamageMeterShowing = isDamageMeterShowing; + fragment.DamageMeterStyleFragmentType = damageMeterStyleFragmentType; } } @@ -394,6 +412,7 @@ private static void SetIsDamageMeterSnapshotShowing(IEnumerable LocalizationController.Translation("SORT_BY_NAME"); public static string TranslationSortByHeal => LocalizationController.Translation("SORT_BY_HEAL"); public static string TranslationSortByHps => LocalizationController.Translation("SORT_BY_HPS"); + public static string TranslationTakenDamage => LocalizationController.Translation("TAKEN_DAMAGE"); public static string TranslationSnapshots => LocalizationController.Translation("SNAPSHOTS"); public static string TranslationDeleteSelectedSnapshot => LocalizationController.Translation("DELETE_SELECTED_SNAPSHOT"); public static string TranslationDeleteAllSnapshots => LocalizationController.Translation("DELETE_ALL_SNAPSHOTS"); diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs index aadbeb3a..f15f5694 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs @@ -31,8 +31,13 @@ public class DamageMeterFragment : BaseViewModel private TimeSpan _combatTime; private double _overhealedPercentageOfTotalHealing; private double _overhealed; + private long _takenDamage; + private string _takenDamageShortString; + private double _takenDamageInPercent; + private double _takenDamagePercentage; + private DamageMeterStyleFragmentType _damageMeterStyleFragmentType; private Visibility _spellsContainerVisibility = Visibility.Collapsed; - private ObservableCollection _spells = new (); + private ObservableCollection _spells = new(); public DamageMeterFragment(DamageMeterFragment damageMeterFragment) { @@ -48,6 +53,9 @@ public DamageMeterFragment(DamageMeterFragment damageMeterFragment) Name = damageMeterFragment.Name; CauserMainHand = damageMeterFragment.CauserMainHand; Spells = damageMeterFragment.Spells; + TakenDamage = damageMeterFragment.TakenDamage; + TakenDamageInPercent = damageMeterFragment.TakenDamageInPercent; + TakenDamagePercentage = damageMeterFragment.TakenDamagePercentage; } public DamageMeterFragment() @@ -84,6 +92,16 @@ public bool IsDamageMeterShowing } } + public DamageMeterStyleFragmentType DamageMeterStyleFragmentType + { + get => _damageMeterStyleFragmentType; + set + { + _damageMeterStyleFragmentType = value; + OnPropertyChanged(); + } + } + public TimeSpan CombatTime { get => _combatTime; @@ -246,6 +264,51 @@ public double OverhealedPercentageOfTotalHealing #endregion + #region Take Damage + + public long TakenDamage + { + get => _takenDamage; + set + { + _takenDamage = value; + TakenDamageShortString = _takenDamage.ToShortNumberString(); + OnPropertyChanged(); + } + } + + public string TakenDamageShortString + { + get => _takenDamageShortString; + private set + { + _takenDamageShortString = value; + OnPropertyChanged(); + } + } + + public double TakenDamageInPercent + { + get => _takenDamageInPercent; + set + { + _takenDamageInPercent = value; + OnPropertyChanged(); + } + } + + public double TakenDamagePercentage + { + get => _takenDamagePercentage; + set + { + _takenDamagePercentage = value; + OnPropertyChanged(); + } + } + + #endregion + #region Spells public ObservableCollection Spells diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs index 2dc5c883..4c02f626 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSnapshotFragment.cs @@ -16,6 +16,11 @@ public sealed class DamageMeterSnapshotFragment : BaseViewModel private double _dps; private long _heal; private double _hps; + private long _takenDamage; + private string _takenDamageShortString; + private double _takenDamageInPercent; + private double _takenDamagePercentage; + private DamageMeterStyleFragmentType _damageMeterStyleFragmentType; private Visibility _spellsContainerVisibility = Visibility.Collapsed; public DamageMeterSnapshotFragment(DamageMeterFragment damageMeterFragment) @@ -31,6 +36,9 @@ public DamageMeterSnapshotFragment(DamageMeterFragment damageMeterFragment) Hps = damageMeterFragment.Hps; HealInPercent = damageMeterFragment.HealInPercent; HealPercentage = damageMeterFragment.HealPercentage; + TakenDamage = damageMeterFragment.TakenDamage; + TakenDamageInPercent = damageMeterFragment.TakenDamageInPercent; + TakenDamagePercentage = damageMeterFragment.TakenDamagePercentage; CauserMainHandItemUniqueName = damageMeterFragment.CauserMainHand?.UniqueName ?? string.Empty; OverhealedPercentageOfTotalHealing = damageMeterFragment.OverhealedPercentageOfTotalHealing; Spells = damageMeterFragment.Spells.Select(x => new SpellsSnapshotFragment() @@ -140,6 +148,61 @@ public Visibility SpellsContainerVisibility #endregion + #region Take Damage + + public long TakenDamage + { + get => _takenDamage; + set + { + _takenDamage = value; + TakenDamageShortString = _damage.ToShortNumberString(); + OnPropertyChanged(); + } + } + + public string TakenDamageShortString + { + get => _takenDamageShortString; + private set + { + _takenDamageShortString = value; + OnPropertyChanged(); + } + } + + public double TakenDamageInPercent + { + get => _takenDamageInPercent; + set + { + _takenDamageInPercent = value; + OnPropertyChanged(); + } + } + + public double TakenDamagePercentage + { + get => _takenDamagePercentage; + set + { + _takenDamagePercentage = value; + OnPropertyChanged(); + } + } + + #endregion + + public DamageMeterStyleFragmentType DamageMeterStyleFragmentType + { + get => _damageMeterStyleFragmentType; + set + { + _damageMeterStyleFragmentType = value; + OnPropertyChanged(); + } + } + private void PerformShowSpells(object value) { SpellsContainerVisibility = SpellsContainerVisibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible; diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSort.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSort.cs index 7b97f5b9..2a2999f4 100644 --- a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSort.cs +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterSort.cs @@ -6,5 +6,6 @@ public enum DamageMeterSortType Dps, Name, Heal, - Hps + Hps, + TakenDamage } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/DamageMeter/DamageMeterStyleFragmentType.cs b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterStyleFragmentType.cs new file mode 100644 index 00000000..f46154f2 --- /dev/null +++ b/src/StatisticsAnalysisTool/DamageMeter/DamageMeterStyleFragmentType.cs @@ -0,0 +1,8 @@ +namespace StatisticsAnalysisTool.DamageMeter; + +public enum DamageMeterStyleFragmentType +{ + Damage, + Heal, + TakenDamage +} \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Localization/localization.json b/src/StatisticsAnalysisTool/Localization/localization.json index e75a1dbe..64c08c23 100644 --- a/src/StatisticsAnalysisTool/Localization/localization.json +++ b/src/StatisticsAnalysisTool/Localization/localization.json @@ -37248,6 +37248,19 @@ "seg": "Ouvrir la validation d'événement" } ] + }, + { + "tuid": "TAKEN_DAMAGE", + "tuv": [ + { + "lang": "de-DE", + "seg": "Erlittener Schaden" + }, + { + "lang": "en-US", + "seg": "Damage suffered" + } + ] } ] } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Models/NetworkModel/PlayerGameObject.cs b/src/StatisticsAnalysisTool/Models/NetworkModel/PlayerGameObject.cs index 76a4cc5e..7e8fb33d 100644 --- a/src/StatisticsAnalysisTool/Models/NetworkModel/PlayerGameObject.cs +++ b/src/StatisticsAnalysisTool/Models/NetworkModel/PlayerGameObject.cs @@ -65,6 +65,7 @@ public List CombatTimes public TimeSpan CombatTime { get; set; } = new(1); public long Damage { get; set; } public long Heal { get; set; } + public long TakenDamage { get; set; } public List Spells { get; set; } = new(); public long Overhealed { get; set; } public double Dps => Utilities.GetValuePerSecondToDouble(Damage, CombatStart, CombatTime, 9999); diff --git a/src/StatisticsAnalysisTool/Network/Handler/HealthUpdateEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/HealthUpdateEventHandler.cs index fc6bbf9d..0f3ed3f3 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/HealthUpdateEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/HealthUpdateEventHandler.cs @@ -16,5 +16,6 @@ public HealthUpdateEventHandler(TrackingController trackingController) : base((i protected override async Task OnActionAsync(HealthUpdateEvent value) { await _trackingController.CombatController.AddDamage(value.AffectedObjectId, value.CauserId, value.HealthChange, value.NewHealthValue, value.CausingSpellIndex); + await _trackingController.CombatController.AddTakenDamage(value.AffectedObjectId, value.CauserId, value.HealthChange, value.NewHealthValue, value.CausingSpellIndex); } } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Handler/HealthUpdatesEventHandler.cs b/src/StatisticsAnalysisTool/Network/Handler/HealthUpdatesEventHandler.cs index 436a6d78..88f0ac14 100644 --- a/src/StatisticsAnalysisTool/Network/Handler/HealthUpdatesEventHandler.cs +++ b/src/StatisticsAnalysisTool/Network/Handler/HealthUpdatesEventHandler.cs @@ -19,6 +19,7 @@ protected override async Task OnActionAsync(HealthUpdatesEvent value) foreach (HealthUpdate healthUpdate in value.HealthUpdates) { await _trackingController.CombatController.AddDamage(healthUpdate.AffectedObjectId, healthUpdate.CauserId, healthUpdate.HealthChange, healthUpdate.NewHealthValue, healthUpdate.CausingSpellIndex); + await _trackingController.CombatController.AddTakenDamage(healthUpdate.AffectedObjectId, healthUpdate.CauserId, healthUpdate.HealthChange, healthUpdate.NewHealthValue, healthUpdate.CausingSpellIndex); } } } \ No newline at end of file diff --git a/src/StatisticsAnalysisTool/Network/Manager/CombatController.cs b/src/StatisticsAnalysisTool/Network/Manager/CombatController.cs index b139d302..8fba6d9d 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/CombatController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/CombatController.cs @@ -37,7 +37,7 @@ public CombatController(TrackingController trackingController, MainWindowViewMod OnDamageUpdate += UpdateDamageMeterUiAsync; #if DEBUG - RunDamageMeterDebugAsync(0, 0); + RunDamageMeterDebugAsync(10, 10); #endif } @@ -99,6 +99,36 @@ public Task AddDamage(long affectedId, long causerId, double healthChange, doubl return Task.CompletedTask; } + public Task AddTakenDamage(long affectedId, long causerId, double healthChange, double newHealthValue, int causingSpellIndex) + { + var healthChangeType = GetHealthChangeType(healthChange); + if (!SettingsController.CurrentSettings.IsDamageMeterTrackingActive || (affectedId == causerId && healthChangeType == HealthChangeType.Damage)) + { + return Task.CompletedTask; + } + + var gameObject = _trackingController?.EntityController?.GetEntity(affectedId); + var gameObjectValue = gameObject?.Value; + + if (gameObject?.Value is not { ObjectType: GameObjectType.Player } || !_trackingController.EntityController.IsEntityInParty(gameObject.Value.Key)) + { + return Task.CompletedTask; + } + + if (healthChangeType == HealthChangeType.Damage) + { + var damageChangeValue = (int) Math.Round(healthChange.ToPositiveFromNegativeOrZero(), MidpointRounding.AwayFromZero); + if (damageChangeValue <= 0) + { + return Task.CompletedTask; + } + + gameObjectValue.TakenDamage += damageChangeValue; + } + + return Task.CompletedTask; + } + private static bool _isUiUpdateActive; public async void UpdateDamageMeterUiAsync(ObservableCollection damageMeter, List> entities) @@ -112,6 +142,7 @@ public async void UpdateDamageMeterUiAsync(ObservableCollection x.CauserGuid == healthChangeObject.Value.UserGuid); if (fragment != null) { - await UpdateDamageMeterFragmentAsync(fragment, healthChangeObject, entities, currentTotalDamage, currentTotalHeal); + await UpdateDamageMeterFragmentAsync(fragment, healthChangeObject, entities, currentTotalDamage, currentTotalHeal, currentTotalTakenDamage); } else { - await AddDamageMeterFragmentAsync(damageMeter, healthChangeObject, entities, currentTotalDamage, currentTotalHeal).ConfigureAwait(true); + await AddDamageMeterFragmentAsync(damageMeter, healthChangeObject, entities, currentTotalDamage, currentTotalHeal, currentTotalTakenDamage).ConfigureAwait(true); } Application.Current.Dispatcher.Invoke(() => _mainWindowViewModel.DamageMeterBindings?.SetDamageMeterSort()); @@ -140,7 +171,7 @@ public async void UpdateDamageMeterUiAsync(ObservableCollection healthChangeObject, - List> entities, long currentTotalDamage, long currentTotalHeal) + List> entities, long currentTotalDamage, long currentTotalHeal, long currentTotalTakenDamage) { var healthChangeObjectValue = healthChangeObject.Value; @@ -157,7 +188,7 @@ private static async Task UpdateDamageMeterFragmentAsync(DamageMeterFragment fra fragment.Damage = healthChangeObjectValue.Damage; } - if (healthChangeObjectValue?.Dps != null) + if (healthChangeObjectValue?.Dps is not null) { fragment.Dps = healthChangeObjectValue.Dps; } @@ -169,7 +200,7 @@ private static async Task UpdateDamageMeterFragmentAsync(DamageMeterFragment fra fragment.Heal = healthChangeObjectValue.Heal; } - if (healthChangeObjectValue?.Hps != null) + if (healthChangeObjectValue?.Hps is not null) { fragment.Hps = healthChangeObjectValue.Hps; } @@ -179,6 +210,13 @@ private static async Task UpdateDamageMeterFragmentAsync(DamageMeterFragment fra fragment.Overhealed = healthChangeObjectValue.Overhealed; } + // Taken Damage + if (healthChangeObjectValue?.TakenDamage > 0) + { + fragment.TakenDamageInPercent = (double) healthChangeObjectValue.TakenDamage / currentTotalTakenDamage * 100; + fragment.TakenDamage = healthChangeObjectValue.TakenDamage; + } + // Spells await AddOrUpdateSpellFragmentAsync(fragment.Spells, healthChangeObjectValue?.Spells); @@ -188,8 +226,12 @@ private static async Task UpdateDamageMeterFragmentAsync(DamageMeterFragment fra fragment.CombatTime = healthChangeObjectValue.CombatTime; fragment.DamagePercentage = entities.GetDamagePercentage(healthChangeObjectValue.Damage); fragment.HealPercentage = entities.GetHealPercentage(healthChangeObjectValue.Heal); + fragment.TakenDamagePercentage = entities.GetTakenDamagePercentage(healthChangeObjectValue.TakenDamage); fragment.OverhealedPercentageOfTotalHealing = GetOverhealedPercentageOfHealWithOverhealed(healthChangeObjectValue.Overhealed, healthChangeObjectValue.Heal); } + + Debug.Print($"AddDamageMeterFragmentAsync - Name: {fragment.Name}, Damage: {fragment.Damage}, Heal: {fragment.Heal}, TakenDamage: {fragment.TakenDamage}"); + } public static double GetOverhealedPercentageOfHealWithOverhealed(double overhealed, double heal) @@ -198,7 +240,7 @@ public static double GetOverhealedPercentageOfHealWithOverhealed(double overheal } private static async Task AddDamageMeterFragmentAsync(ICollection damageMeter, KeyValuePair healthChangeObject, - List> entities, long currentTotalDamage, long currentTotalHeal) + List> entities, long currentTotalDamage, long currentTotalHeal, long currentTotalTakenDamage) { if (healthChangeObject.Value == null || (double.IsNaN(healthChangeObject.Value.Damage) && double.IsNaN(healthChangeObject.Value.Heal) && double.IsNaN(healthChangeObject.Value.Overhealed)) @@ -228,12 +270,16 @@ private static async Task AddDamageMeterFragmentAsync(ICollection { damageMeter.Add(damageMeterFragment); @@ -330,6 +376,7 @@ public void ResetDamageMeter() _trackingController.EntityController.ResetEntitiesDamageTimes(); _trackingController.EntityController.ResetEntitiesDamage(); _trackingController.EntityController.ResetEntitiesHeal(); + _trackingController.EntityController.ResetEntitiesTakeDamage(); _trackingController.EntityController.ResetSpells(); _trackingController.EntityController.ResetEntitiesHealAndOverhealed(); _trackingController.EntityController.ResetEntitiesDamageStartTime(); @@ -569,7 +616,9 @@ private async Task AddDamageAsync(PlayerGameObject entity, int runs) for (var i = 0; i < runs; i++) { var damage = Random.Next(-5000, 5000); + var takenDamage = Random.Next(-5000, 5000); await AddDamage(9999, entity.ObjectId ?? -1, damage, Random.Next(2000, 3000), Random.Next(2000, 3000)); + await AddTakenDamage(entity.ObjectId ?? -1, 9999, takenDamage, Random.Next(2000, 3000), Random.Next(2000, 3000)); //Debug.Print($"--- AddDamage - {entity.Name}: {damage}"); await Task.Delay(Random.Next(1, 1000)); diff --git a/src/StatisticsAnalysisTool/Network/Manager/EntityController.cs b/src/StatisticsAnalysisTool/Network/Manager/EntityController.cs index 004709f9..4e7fd552 100644 --- a/src/StatisticsAnalysisTool/Network/Manager/EntityController.cs +++ b/src/StatisticsAnalysisTool/Network/Manager/EntityController.cs @@ -525,6 +525,14 @@ public void ResetEntitiesHeal() } } + public void ResetEntitiesTakeDamage() + { + foreach (var entity in _knownEntities) + { + entity.Value.TakenDamage = 0; + } + } + public void ResetSpells() { foreach (var entity in _knownEntities) diff --git a/src/StatisticsAnalysisTool/Styles/Colors.xaml b/src/StatisticsAnalysisTool/Styles/Colors.xaml index ed9cce9f..3a87d70c 100644 --- a/src/StatisticsAnalysisTool/Styles/Colors.xaml +++ b/src/StatisticsAnalysisTool/Styles/Colors.xaml @@ -315,7 +315,8 @@ - + + diff --git a/src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml b/src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml index 33ad4442..f8bd01e7 100644 --- a/src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml +++ b/src/StatisticsAnalysisTool/Styles/DamageMeterStyles.xaml @@ -122,13 +122,11 @@ @@ -174,11 +172,51 @@ + + + + + + + + + + + + + + @@ -299,14 +335,54 @@ - + + + + + + + + + + + + + + +