diff --git a/WotBlitzStatisticsPro.Blazor/Constants.cs b/WotBlitzStatisticsPro.Blazor/Constants.cs index 916bbdb..6db0e75 100644 --- a/WotBlitzStatisticsPro.Blazor/Constants.cs +++ b/WotBlitzStatisticsPro.Blazor/Constants.cs @@ -24,6 +24,20 @@ public const string ScaleUnicumColor = "#a785bb"; public const string ScaleSuperUnicumColor = "#8348ab"; + public const string HeavyTank = "heavyTank"; + public const string AtSpg = "AT-SPG"; + public const string MediumTank = "mediumTank"; + public const string LightTank = "lightTank"; + + public const string CountryUsa = "usa"; + public const string CountryFrance = "france"; + public const string CountryUssr = "ussr"; + public const string CountryChina = "china"; + public const string CountryUk = "uk"; + public const string CountryJapan = "japan"; + public const string CountryGermany = "germany"; + public const string CountryOther = "other"; + public const string CountryEuropean = "european"; } } \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Helpers/AssetsHelper.cs b/WotBlitzStatisticsPro.Blazor/Helpers/AssetsHelper.cs index 186945f..cd788ef 100644 --- a/WotBlitzStatisticsPro.Blazor/Helpers/AssetsHelper.cs +++ b/WotBlitzStatisticsPro.Blazor/Helpers/AssetsHelper.cs @@ -20,14 +20,14 @@ namespace WotBlitzStatisticsPro.Blazor.Helpers { return tankTypeId switch { - "heavyTank" when !isPremium => "/tank-type/vehicle.class.heavy.small.scale-200.png", - "heavyTank" when isPremium => "/tank-type/vehicle.class.heavy.premium.small.scale-200.png", - "AT-SPG" when !isPremium => "/tank-type/vehicle.class.atspg.small.scale-200.png", - "AT-SPG" when isPremium => "/tank-type/vehicle.class.atspg.premium.small.scale-200.png", - "mediumTank" when !isPremium => "/tank-type/vehicle.class.medium.small.scale-200.png", - "mediumTank" when isPremium => "/tank-type/vehicle.class.medium.premium.small.scale-200.png", - "lightTank" when !isPremium => "/tank-type/vehicle.class.light.small.scale-200.png", - "lightTank" when isPremium => "/tank-type/vehicle.class.light.premium.small.scale-200.png", + Constants.HeavyTank when !isPremium => "/tank-type/vehicle.class.heavy.small.scale-200.png", + Constants.HeavyTank when isPremium => "/tank-type/vehicle.class.heavy.premium.small.scale-200.png", + Constants.AtSpg when !isPremium => "/tank-type/vehicle.class.atspg.small.scale-200.png", + Constants.AtSpg when isPremium => "/tank-type/vehicle.class.atspg.premium.small.scale-200.png", + Constants.MediumTank when !isPremium => "/tank-type/vehicle.class.medium.small.scale-200.png", + Constants.MediumTank when isPremium => "/tank-type/vehicle.class.medium.premium.small.scale-200.png", + Constants.LightTank when !isPremium => "/tank-type/vehicle.class.light.small.scale-200.png", + Constants.LightTank when isPremium => "/tank-type/vehicle.class.light.premium.small.scale-200.png", _ => "" }; } @@ -36,15 +36,15 @@ namespace WotBlitzStatisticsPro.Blazor.Helpers { return nationTypeId switch { - "usa" => "flags/usa.png", - "france" => "flags/france.png", - "ussr" => "flags/ussr.png", - "china" => "flags/china.png", - "uk" => "flags/uk.png", - "japan" => "flags/japan.png", - "germany" => "flags/germany.png", - "other" => "flags/other.png", - "european" => "flags/eu.png", + Constants.CountryUsa => "flags/usa.png", + Constants.CountryFrance => "flags/france.png", + Constants.CountryUssr => "flags/ussr.png", + Constants.CountryChina => "flags/china.png", + Constants.CountryUk => "flags/uk.png", + Constants.CountryJapan => "flags/japan.png", + Constants.CountryGermany => "flags/germany.png", + Constants.CountryOther => "flags/other.png", + Constants.CountryEuropean => "flags/eu.png", _ => "flags/vehicle.nation.unknown.scale-200.png" }; } diff --git a/WotBlitzStatisticsPro.Blazor/Model/FilterItem.cs b/WotBlitzStatisticsPro.Blazor/Model/FilterItem.cs new file mode 100644 index 0000000..a108fcc --- /dev/null +++ b/WotBlitzStatisticsPro.Blazor/Model/FilterItem.cs @@ -0,0 +1,4 @@ +namespace WotBlitzStatisticsPro.Blazor.Model +{ + public record FilterItem(T ItemId, string ItemName); +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Model/SearchItem.cs b/WotBlitzStatisticsPro.Blazor/Model/SearchItem.cs deleted file mode 100644 index 97f5401..0000000 --- a/WotBlitzStatisticsPro.Blazor/Model/SearchItem.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace WotBlitzStatisticsPro.Blazor.Model -{ - [Obsolete("This is temporary item. In the future there should be two new data models with 'clan, winrate and battles' for player, and 'name, tag members count' for clan")] - public record SearchItem(long ItemId, string ItemName); - -} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksList.razor b/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksList.razor index eefdf29..0f4b5e1 100644 --- a/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksList.razor +++ b/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksList.razor @@ -1,19 +1,67 @@ @using WotBlitzStatisticsPro.Blazor.Helpers -@inject TooltipService TooltipService -@inject IStringLocalizer Localize +@inherits PlayerInfoTanksListBase; +
+
+ +
+
+ + + +
+
+ OnFilterChange(args)) /> +
+
+ + + +
+
+ + + +
+
+ OnFilterChange(args)) /> +
+
+ LogicalFilterOperator="LogicalFilterOperator.Or" + @ref="TanksGrid"> - + @@ -38,8 +86,16 @@ - - + + + @Localize["Tanks"]: @TanksGrid.View.Count() @Localize["of"] @TanksList.Count() + + + + + @TotalBattles.ToString("N0") + + + + ∼@AvgWinRate% +
+
+ + ∼@AvgWn7.ToString("N0")% +
+
+
+ + + ∼@AvgTotalDamage.ToString("N0") + + + + + ∼@AvgTotalXp.ToString("N0") + - - - + FormatString="{0:N0}%"> + + ∼@AvgSurvivalRate.ToString("N0")% + +
- -@code { - [Parameter] - public IEnumerable TanksList { get; set; } - - void ShowTooltip(ElementReference elementReference, string message, TooltipOptions options = null) => TooltipService.Open(elementReference, message, options); - - void OnChange() - { - // Filter - dropdown with multiselect - // https://blazor.radzen.com/datagrid-filter-template - // TanksList = TanksList.Where(e => currentTOC >= 0 ? e.TitleOfCourtesy == currentTOC : true); - } - -} diff --git a/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksListBase.cs b/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksListBase.cs new file mode 100644 index 0000000..dcd2a45 --- /dev/null +++ b/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksListBase.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; +using Radzen; +using Radzen.Blazor; +using WotBlitzStatisticsPro.Blazor.GraphQl; +using WotBlitzStatisticsPro.Blazor.Helpers; +using WotBlitzStatisticsPro.Blazor.Model; + +namespace WotBlitzStatisticsPro.Blazor.Pages +{ + public class PlayerInfoTanksListBase: ComponentBase + { + [Parameter] + public IEnumerable TanksList { get; set; } + + [Inject] + public TooltipService TooltipService { get; set; } + + [Inject] + public IStringLocalizer Localize { get; set; } + + public RadzenDataGrid TanksGrid { get; set; } + + public IEnumerable FilteredTankList { get; set; } + + public List> TierFilter { get; set; } = new(); + public IEnumerable FilteredTiers { get; set; } = new int[] { }; + + public List> TankTypesFilter { get; set; } = new(); + public IEnumerable FilteredTankTypes { get; set; } = new string[] { }; + + public bool? FilterIsPremium { get; set; } = null; + + public List> NationsFilter { get; set; } = new(); + public IEnumerable FilteredNations { get; set; } = new string[] { }; + + public List> MasteryFilter { get; set; } = new(); + public IEnumerable FilteredMastery { get; set; } = new MarkOfMastery[] { }; + + public int TotalBattles { get; set; } + public int AvgWinRate { get; set; } + public double AvgWn7 { get; set; } + public int AvgTotalDamage { get; set; } + public int AvgTotalXp { get; set; } + public int AvgSurvivalRate { get; set; } + public int? MinBattles { get; set; } = null; + + protected override void OnInitialized() + { + FilteredTankList = TanksList; + CountTotalParams(); + for (int i = 1; i < 11; i++) + { + TierFilter.Add(new FilterItem(i, i.RomanNumber())); + } + FillTankTypesFilter(); + FillNationsFilter(); + FillMasteryFilter(); + } + + public void ShowTooltip(ElementReference elementReference, string message, TooltipOptions options = null) => TooltipService.Open(elementReference, message, options); + + public void OnFilterChange(object value) + { + FilteredTankList = TanksList; + if (FilteredTiers.Any()) + { + FilteredTankList = FilteredTankList.Where(t => FilteredTiers.Contains(t.Tier)); + } + if (FilteredTankTypes.Any()) + { + FilteredTankList = FilteredTankList.Where(t => FilteredTankTypes.Contains(t.TankTypeId)); + } + if (FilterIsPremium.HasValue) + { + FilteredTankList = FilteredTankList.Where(t => t.IsPremium == FilterIsPremium.Value); + } + if (FilteredNations.Any()) + { + FilteredTankList = FilteredTankList.Where(t => FilteredNations.Contains(t.TankNationId)); + } + if (FilteredMastery.Any()) + { + FilteredTankList = FilteredTankList.Where(t => FilteredMastery.Contains(t.MarkOfMastery)); + } + if (MinBattles.HasValue) + { + FilteredTankList = FilteredTankList.Where(t => t.Battles > MinBattles.Value); + } + + CountTotalParams(); + } + + private void FillTankTypesFilter() + { + // ToDo: Should get values from Dictionary here instead of hard code + TankTypesFilter.Add(new FilterItem(Constants.HeavyTank, Constants.HeavyTank.TankTypeAsset(false))); + TankTypesFilter.Add(new FilterItem(Constants.AtSpg, Constants.AtSpg.TankTypeAsset(false))); + TankTypesFilter.Add(new FilterItem(Constants.MediumTank, Constants.MediumTank.TankTypeAsset(false))); + TankTypesFilter.Add(new FilterItem(Constants.LightTank, Constants.LightTank.TankTypeAsset(false))); + } + + private void FillNationsFilter() + { + // ToDo: Should get values from Dictionary here instead of hard code + NationsFilter.Add(new FilterItem(Constants.CountryUsa, Constants.CountryUsa.NationAsset())); + NationsFilter.Add(new FilterItem(Constants.CountryFrance, Constants.CountryFrance.NationAsset())); + NationsFilter.Add(new FilterItem(Constants.CountryUssr, Constants.CountryUssr.NationAsset())); + NationsFilter.Add(new FilterItem(Constants.CountryChina, Constants.CountryChina.NationAsset())); + NationsFilter.Add(new FilterItem(Constants.CountryUk, Constants.CountryUk.NationAsset())); + NationsFilter.Add(new FilterItem(Constants.CountryJapan, Constants.CountryJapan.NationAsset())); + NationsFilter.Add(new FilterItem(Constants.CountryGermany, Constants.CountryGermany.NationAsset())); + NationsFilter.Add(new FilterItem(Constants.CountryOther, Constants.CountryOther.NationAsset())); + NationsFilter.Add(new FilterItem(Constants.CountryEuropean, Constants.CountryEuropean.NationAsset())); + } + + private void FillMasteryFilter() + { + foreach (MarkOfMastery mastery in Enum.GetValues(typeof(MarkOfMastery))) + { + MasteryFilter.Add(new FilterItem(mastery, mastery.IconAsset())); + } + } + + private void CountTotalParams() + { + TotalBattles = Convert.ToInt32(FilteredTankList.Sum(t => t.Battles)); + if (TotalBattles > 0) + { + AvgWinRate = Convert.ToInt32(100 * FilteredTankList.Sum(t => t.Wins) / TotalBattles); + AvgWn7 = Convert.ToDouble(FilteredTankList.Sum(t => t.Wn7)) / FilteredTankList.Count(); + AvgTotalDamage = Convert.ToInt32(FilteredTankList.Sum(t => t.DamageDealt) / TotalBattles); + AvgTotalXp = Convert.ToInt32(FilteredTankList.Sum(t => t.Xp) / TotalBattles); + AvgSurvivalRate = Convert.ToInt32(100 * FilteredTankList.Sum(t => t.WinAndSurvived) / TotalBattles); + } + else + { + AvgWinRate = 0; + AvgWn7 = 0; + AvgTotalDamage = 0; + AvgTotalXp = 0; + AvgSurvivalRate = 0; + } + } + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Resources/App.de.resx b/WotBlitzStatisticsPro.Blazor/Resources/App.de.resx index df5d539..6403033 100644 --- a/WotBlitzStatisticsPro.Blazor/Resources/App.de.resx +++ b/WotBlitzStatisticsPro.Blazor/Resources/App.de.resx @@ -132,6 +132,18 @@ vor Tagen + + Meisterschaftfilter... + + + Nationfilter... + + + Panzertypenfilter... + + + Rangfilter... + Startseite @@ -150,12 +162,21 @@ Mitglieder + + Min Schlachten + vor Minuten vor Monaten + + von + + + Prämiepanzern + Region @@ -171,6 +192,9 @@ Panzer + + Panzern + Willkommen bei der WOT Blitz statistics! diff --git a/WotBlitzStatisticsPro.Blazor/Resources/App.ru.resx b/WotBlitzStatisticsPro.Blazor/Resources/App.ru.resx index ea61949..92da465 100644 --- a/WotBlitzStatisticsPro.Blazor/Resources/App.ru.resx +++ b/WotBlitzStatisticsPro.Blazor/Resources/App.ru.resx @@ -132,6 +132,18 @@ дней назад + + Фильтр по знаку мастер... + + + Фильтр по нациям... + + + Фильтр по типу танка... + + + Фильтр по уровню... + На главную @@ -150,12 +162,21 @@ Участников + + Мин боёв + минут назад месяцев назад + + из + + + Премиум танки + Регион @@ -171,6 +192,9 @@ Танк + + Танков + Добро пожаловать в WOT Blitz statistics!