public double GetWinRate(ReferencePeriod period = ReferencePeriod.All, int minTier = 1, int maxTier = 10, bool?isPremium = null, TankType?type = null) { var tanks = GetTanks(period, minTier, maxTier, isPremium, type).ToArray(); if (!tanks.Any()) { return(0.0); } return(tanks.Sum(t => t.Wins * 1.0) / tanks.Sum(t => t.Battles)); }
public IEnumerable <TankPlayerStatistics> WithMedal(ReferencePeriod period, string medalCode) { var all = All.Values; if (period == ReferencePeriod.Month) { all = Month.Values; } else if (period == ReferencePeriod.Week) { all = Week.Values; } return(all.Where(t => t.WithMedal(medalCode))); }
public IEnumerable <TankPlayerStatistics> GetTanks(ReferencePeriod period = ReferencePeriod.All, int minTier = 1, int maxTier = 10, bool?isPremium = null, TankType?type = null, int?minBattles = null, Nation?nation = null) { Dictionary <long, TankPlayerStatistics> dic; switch (period) { case ReferencePeriod.Month: dic = Month; break; case ReferencePeriod.Week: dic = Week; break; case ReferencePeriod.All: dic = All; break; default: throw new ArgumentOutOfRangeException(nameof(period), period, null); } var tanks = dic.Values.Where(t => (minTier <= t.Tier) && (t.Tier <= maxTier)); if (isPremium.HasValue) { tanks = tanks.Where(t => t.IsPremium == isPremium.Value); } if (type.HasValue) { tanks = tanks.Where(t => t.Type == type.Value); } if (minBattles.HasValue) { tanks = tanks.Where(t => t.Battles >= minBattles.Value); } if (nation.HasValue) { tanks = tanks.Where(t => t.Nation == nation.Value); } return(tanks.ToArray()); }
/// <summary> /// Top tanks by WN8 /// </summary> public IEnumerable <TankPlayerStatistics> GetTopTanks(ReferencePeriod period = ReferencePeriod.All, int minNumberOfTanks = 5, int minTier = 1, int maxTier = 10, PremiumSelection includePremiums = PremiumSelection.OnlyRegular, int minBattles = 1, HashSet <Nation> nationsFilters = null, HashSet <TankType> typesFilter = null) { var all = GetTanks(period, minTier, maxTier, minBattles: minBattles).ToArray(); if (nationsFilters != null && nationsFilters.Count > 0) { all = all.Where(t => nationsFilters.Contains(t.Nation)).ToArray(); } if (typesFilter != null && typesFilter.Count > 0) { all = all.Where(t => typesFilter.Contains(t.Type)).ToArray(); } all = all.Where(t => includePremiums.Filter(t.IsPremium)).ToArray(); var top = FilterTopTanks(all, minNumberOfTanks, t => t.Wn8); return(top.Any() ? top : Array.Empty <TankPlayerStatistics>()); }
public double GetWn8(ReferencePeriod period = ReferencePeriod.All, int minTier = 1, int maxTier = 10, bool?isPremium = null, TankType?type = null) { var tanks = GetTanks(period, minTier, maxTier, isPremium, type); return(ExpectedValues.CalculateWn8(tanks)); }
public TimeSpan GetTime(ReferencePeriod period = ReferencePeriod.All, int minTier = 1, int maxTier = 10, bool?isPremium = null, TankType?type = null) { var tanks = GetTanks(period, minTier, maxTier, isPremium, type); return(TimeSpan.FromSeconds(tanks.Sum(t => t.BattleLifeTimeSeconds))); }
public int GetBattles(ReferencePeriod period = ReferencePeriod.All, int minTier = 1, int maxTier = 10, bool?isPremium = null, TankType?type = null) { var tanks = GetTanks(period, minTier, maxTier, isPremium, type); return((int)tanks.Sum(t => t.Battles)); }
public TankPlayerStatistics GetBestTank(ReferencePeriod period = ReferencePeriod.All) { return(GetTopTanks(period, 25, 5).FirstOrDefault() ?? All.Values.OrderByDescending(t => t.Wn8).FirstOrDefault()); }
public IEnumerable <TankPlayerStatistics> GetTopTanks(ReferencePeriod period = ReferencePeriod.All, int minNumberOfTanks = 5, int minTier = 1, int maxTier = 10, bool includePremiums = false) { var all = GetTanks(period, minTier, maxTier).ToArray(); var top = all.Where(t => t.Battles >= 2500 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 1000 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 500 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 250 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 100 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 50 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 25 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 10 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 5 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } top = all.Where(t => t.Battles >= 1 && (!t.IsPremium || includePremiums)).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); if (top.Length >= minNumberOfTanks) { return(top); } if (top.Any()) { return(top); } // new player, very few higher tiers top = GetTanks(period, 1, 10).Where(t => t.Battles >= 1).OrderByDescending(t => t.Wn8).Take(minNumberOfTanks).ToArray(); return(top); }