Added tanks stat info operation and calculation tier and Wn7 operation

This commit is contained in:
Mikhail Shabanov committed 2020-09-22 17:54:35 +02:00
1 parent 3eeda15491
commit b343e36e0d
14 files changed
+394 -4

No files matched your search

@@ -0,0 +1,28 @@
using System.Collections.Generic;
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
namespace WotBlitzStatisticsPro.Logic.Calculations
{
public static class TierHelper
{
public static void CalculateMiddleTier(this AccountInfoHistory account, IList<TankInfoHistory> allTanks, Dictionary<long, int> tankTires)
{
double x = 0d;
if (!account.Battles.HasValue)
{
return;
}
foreach (var tank in allTanks)
{
if (tankTires.ContainsKey(tank.TankId) && tank.Battles.HasValue && tank.Battles > 0)
{
x += tankTires[tank.TankId] * tank.Battles.Value;
}
}
if (account.Battles > 0)
x /= account.Battles.Value;
account.AvgTier = x;
}
}
}