2020-09-22 17:54:35 +02:00
|
|
|
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)
|
|
|
|
|
{
|
2020-09-30 19:30:36 +02:00
|
|
|
if (tankTires.ContainsKey(tank.TankId) && tank.Battles > 0)
|
2020-09-22 17:54:35 +02:00
|
|
|
{
|
2021-01-05 13:04:13 +01:00
|
|
|
x += tankTires[tank.TankId] * tank.Battles.DoubleValue();
|
2020-09-22 17:54:35 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (account.Battles > 0)
|
|
|
|
|
x /= account.Battles.Value;
|
|
|
|
|
account.AvgTier = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|