From b24437cb820ed7d5987069872625325b1758c718 Mon Sep 17 00:00:00 2001 From: milimoe Date: Sat, 28 Oct 2023 19:08:58 +0800 Subject: [PATCH] Modify GameStatistics (2) --- Entity/Statistics/GameStatistics.cs | 52 ++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/Entity/Statistics/GameStatistics.cs b/Entity/Statistics/GameStatistics.cs index 8bc6688..79fe591 100644 --- a/Entity/Statistics/GameStatistics.cs +++ b/Entity/Statistics/GameStatistics.cs @@ -12,10 +12,54 @@ namespace Milimoe.FunGame.Core.Entity public Dictionary PhysicalDamageStats { get; } = new(); public Dictionary MagicDamageStats { get; } = new(); public Dictionary RealDamageStats { get; } = new(); - public Dictionary AvgDamageStats { get; } = new(); - public Dictionary AvgPhysicalDamageStats { get; } = new(); - public Dictionary AvgMagicDamageStats { get; } = new(); - public Dictionary AvgRealDamageStats { get; } = new(); + public decimal AvgDamageStats + { + get + { + decimal total = 0; + foreach (User user in DamageStats.Keys) + { + total += DamageStats[user]; + } + return Math.Round(total / DamageStats.Count, 2); + } + } + public decimal AvgPhysicalDamageStats + { + get + { + decimal total = 0; + foreach (User user in PhysicalDamageStats.Keys) + { + total += PhysicalDamageStats[user]; + } + return Math.Round(total / PhysicalDamageStats.Count, 2); + } + } + public decimal AvgMagicDamageStats + { + get + { + decimal total = 0; + foreach (User user in MagicDamageStats.Keys) + { + total += MagicDamageStats[user]; + } + return Math.Round(total / MagicDamageStats.Count, 2); + } + } + public decimal AvgRealDamageStats + { + get + { + decimal total = 0; + foreach (User user in RealDamageStats.Keys) + { + total += RealDamageStats[user]; + } + return Math.Round(total / RealDamageStats.Count, 2); + } + } public Dictionary KillStats { get; } = new(); public Dictionary> KillDetailStats { get; } = new(); // 子字典记录的是被击杀者以及被击杀次数 public Dictionary DeathStats { get; } = new();