Skip to content

Commit

Permalink
Merge branch 'TakenDamageMeter'
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Jul 25, 2024
2 parents af6b194 + 450b971 commit 6bf3c33
Show file tree
Hide file tree
Showing 15 changed files with 363 additions and 44 deletions.
12 changes: 12 additions & 0 deletions src/StatisticsAnalysisTool/Common/ExtensionMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ public static long GetCurrentTotalHeal(this List<KeyValuePair<Guid, PlayerGameOb
return playerObjects.Count <= 0 ? 0 : playerObjects.Max(x => x.Value.Heal);
}

public static long GetCurrentTotalTakenDamage(this List<KeyValuePair<Guid, PlayerGameObject>> playerObjects)
{
return playerObjects.Count <= 0 ? 0 : playerObjects.Max(x => x.Value.TakenDamage);
}


public static double GetDamagePercentage(this List<KeyValuePair<Guid, PlayerGameObject>> playerObjects, double playerDamage)
{
var totalDamage = playerObjects.Sum(x => x.Value.Damage);
Expand All @@ -273,6 +279,12 @@ public static double GetHealPercentage(this List<KeyValuePair<Guid, PlayerGameOb
return 100.00 / totalHeal * playerHeal;
}

public static double GetTakenDamagePercentage(this List<KeyValuePair<Guid, PlayerGameObject>> playerObjects, double playerDamage)
{
var totalTakenDamage = playerObjects.Sum(x => x.Value.TakenDamage);
return 100.00 / totalTakenDamage * playerDamage;
}

#endregion

#region DateTime
Expand Down
49 changes: 34 additions & 15 deletions src/StatisticsAnalysisTool/DamageMeter/DamageMeterBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ public DamageMeterBindings()
Name = TranslationSortByHps,
DamageMeterSortType = DamageMeterSortType.Hps
};
var takenDamageStruct = new DamageMeterSortStruct
{
Name = TranslationTakenDamage,
DamageMeterSortType = DamageMeterSortType.TakenDamage
};

DamageMeterSort.Clear();
DamageMeterSort.Add(sortByDamageStruct);
DamageMeterSort.Add(sortByDpsStruct);
DamageMeterSort.Add(sortByNameStruct);
DamageMeterSort.Add(sortByHealStruct);
DamageMeterSort.Add(sortByHpsStruct);
DamageMeterSort.Add(takenDamageStruct);
DamageMeterSortSelection = sortByDamageStruct;

DamageMeterSnapshotSort.Clear();
Expand All @@ -76,6 +82,7 @@ public DamageMeterBindings()
DamageMeterSnapshotSort.Add(sortByNameStruct);
DamageMeterSnapshotSort.Add(sortByHealStruct);
DamageMeterSnapshotSort.Add(sortByHpsStruct);
DamageMeterSnapshotSort.Add(takenDamageStruct);
DamageMeterSnapshotSortSelection = sortByDamageStruct;

IsSnapshotAfterMapChangeActive = SettingsController.CurrentSettings.IsSnapshotAfterMapChangeActive;
Expand Down Expand Up @@ -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<DamageMeterFragment> damageMeter, bool isDamageMeterShowing)
private static void SetIsDamageMeterShowing(IEnumerable<DamageMeterFragment> damageMeter, DamageMeterStyleFragmentType damageMeterStyleFragmentType)
{
foreach (var fragment in damageMeter)
{
fragment.IsDamageMeterShowing = isDamageMeterShowing;
fragment.DamageMeterStyleFragmentType = damageMeterStyleFragmentType;
}
}

Expand Down Expand Up @@ -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<DamageMeterSnapshotFragment> damageMeter, bool isDamageMeterShowing)
private static void SetIsDamageMeterSnapshotShowing(IEnumerable<DamageMeterSnapshotFragment> damageMeter, DamageMeterStyleFragmentType damageMeterStyleFragmentType)
{
foreach (var fragment in damageMeter ?? new List<DamageMeterSnapshotFragment>())
{
fragment.IsDamageMeterShowing = isDamageMeterShowing;
fragment.DamageMeterStyleFragmentType = damageMeterStyleFragmentType;
}
}

Expand All @@ -394,6 +412,7 @@ private static void SetIsDamageMeterSnapshotShowing(IEnumerable<DamageMeterSnaps
public static string TranslationSortByName => 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");
Expand Down
65 changes: 64 additions & 1 deletion src/StatisticsAnalysisTool/DamageMeter/DamageMeterFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UsedSpellFragment> _spells = new ();
private ObservableCollection<UsedSpellFragment> _spells = new();

public DamageMeterFragment(DamageMeterFragment damageMeterFragment)
{
Expand All @@ -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()
Expand Down Expand Up @@ -84,6 +92,16 @@ public bool IsDamageMeterShowing
}
}

public DamageMeterStyleFragmentType DamageMeterStyleFragmentType
{
get => _damageMeterStyleFragmentType;
set
{
_damageMeterStyleFragmentType = value;
OnPropertyChanged();
}
}

public TimeSpan CombatTime
{
get => _combatTime;
Expand Down Expand Up @@ -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<UsedSpellFragment> Spells
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/StatisticsAnalysisTool/DamageMeter/DamageMeterSort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public enum DamageMeterSortType
Dps,
Name,
Heal,
Hps
Hps,
TakenDamage
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace StatisticsAnalysisTool.DamageMeter;

public enum DamageMeterStyleFragmentType
{
Damage,
Heal,
TakenDamage
}
13 changes: 13 additions & 0 deletions src/StatisticsAnalysisTool/Localization/localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public List<ActionInterval> 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<UsedSpell> Spells { get; set; } = new();
public long Overhealed { get; set; }
public double Dps => Utilities.GetValuePerSecondToDouble(Damage, CombatStart, CombatTime, 9999);
Expand Down
Loading

0 comments on commit 6bf3c33

Please sign in to comment.