From 5fe3c458e1d03214bcf9ae425d7861c3f5d5b206 Mon Sep 17 00:00:00 2001 From: Mikhail Shabanov Date: Wed, 17 Aug 2022 09:44:24 +0200 Subject: [PATCH] feat: tank tree helper --- WotBlitzStatisticsPro.Blazor/Constants.cs | 44 ++++++++++++++++++- .../Pages/PlayerInfoTanksTree.razor | 2 +- .../Pages/PlayerInfoTanksTreeBase.cs | 34 -------------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/WotBlitzStatisticsPro.Blazor/Constants.cs b/WotBlitzStatisticsPro.Blazor/Constants.cs index 01b0d39..1a6de62 100644 --- a/WotBlitzStatisticsPro.Blazor/Constants.cs +++ b/WotBlitzStatisticsPro.Blazor/Constants.cs @@ -1,4 +1,5 @@ -using WotBlitzStatisticsPro.Blazor.Model; +using System; +using WotBlitzStatisticsPro.Blazor.Model; namespace WotBlitzStatisticsPro.Blazor { @@ -44,9 +45,48 @@ namespace WotBlitzStatisticsPro.Blazor public const string LoginInfoLocalStorageKey = "login_info"; + /* + * Mongo express filter: + * {"NationId": "germany", "IsPremium": false, "Tier": 9} + * Projection: + * {"Tier" : true,"Name": { $slice: 1 }} + */ + [Obsolete("Do this as the dictionary in the DB, to make possibility to change it in the future")] public static TankTreeRowMap[] TanksTreeHelper = new TankTreeRowMap[] { - new TankTreeRowMap(2065,2) + // Germany + new TankTreeRowMap(2065, 2), // First tank in a tree + new TankTreeRowMap(1809, 1), // Hetzer (4) + new TankTreeRowMap(17425, 3), // Pz.Kpfw. IV Ausf. D (4) + + new TankTreeRowMap(17, 3), // Pz.Kpfw. IV Ausf. G (5) + new TankTreeRowMap(5393, 7), // VK 16.02 Leopard (5) + + new TankTreeRowMap(1553, 1), // Jagdpanzer IV (6) + new TankTreeRowMap(2321, 5), // VK 36.01 (H) (6) + new TankTreeRowMap(7185, 3), // VK 30.01 (P) 6) + new TankTreeRowMap(10001, 8), // VK 28.01 (6) + new TankTreeRowMap(11793, 0), // Nashorn (6) + new TankTreeRowMap(14097, 6), // VK 30.01 (D) (6) + + new TankTreeRowMap(1297, 6), // Panther I (7) + new TankTreeRowMap(3857, 1), // Jagdpanther (7) + new TankTreeRowMap(4113, 7), // VK 30.02 (D) 7) + new TankTreeRowMap(11025, 0), // Sturer Emil (7) + + new TankTreeRowMap(5137, 5), // Tiger II (8) + new TankTreeRowMap(7697, 2), // Ferdinand (8) + new TankTreeRowMap(8465, 6), // Panther II (8) + new TankTreeRowMap(10513, 3), // VK 45.02 (P) Ausf. A (8) + new TankTreeRowMap(11537, 1), // Jagdpanther II (8) + new TankTreeRowMap(13841, 7), // Indien-Panzer (8) + new TankTreeRowMap(18449, 8), // Ru 251 (8) + new TankTreeRowMap(20497, 4), // VK 100.01 (P) (8) + + new TankTreeRowMap(7953, 1), // Jagdtiger (9) + new TankTreeRowMap(14865, 7), // Leopard Prototyp A (9) + + }; } } \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTree.razor b/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTree.razor index 1f35c86..40b785c 100644 --- a/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTree.razor +++ b/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTree.razor @@ -65,7 +65,7 @@ - + @(tank.WinRate.Value.ToString("N0"))% diff --git a/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTreeBase.cs b/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTreeBase.cs index 43b6345..53559aa 100644 --- a/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTreeBase.cs +++ b/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTreeBase.cs @@ -107,9 +107,6 @@ namespace WotBlitzStatisticsPro.Blazor.Pages } } - // var firstTank = vehiclesTree.First(v => v.Tier == 1); - // TreeItems.AddRange(BuildTree(firstTank, 0, vehiclesTree)); - int maxNonPremTreeRow = GetMaxRowNumber(TreeItems); // TODO: build matrix and connections @@ -199,37 +196,6 @@ namespace WotBlitzStatisticsPro.Blazor.Pages return currentRow; } - [Obsolete] - private List BuildTree(IDictionary_Vehicles firstTank, int rowNumber, List vehiclesTree) - { - var result = new List(); - result.Add(BuildNonPremTreeItem(firstTank, rowNumber)); - - var nextTierTanks = vehiclesTree.Where( - v => firstTank.NexTanksInTree != null && firstTank.NexTanksInTree.Contains(v.TankId)).ToList(); - - if (nextTierTanks.Count == 1) - { - result.AddRange(BuildTree(nextTierTanks[0], rowNumber, vehiclesTree)); - return result; - } - - // If more than one, sort them AT first, Heavy, Middle and light - int nextRow = rowNumber; - string[] tankTypes = { "AT-SPG", "heavyTank", "mediumTank", "lightTank" }; - foreach (var tankType in tankTypes) - { - foreach (var nextTierTank in nextTierTanks.Where(t => t.TypeId == tankType)) - { - var branch = BuildTree(nextTierTank, nextRow, vehiclesTree); - result.AddRange(branch); - nextRow += GetMaxRowNumber(branch); - } - } - - return result; - } - private TankTreeItem BuildNonPremTreeItem(IDictionary_Vehicles vehicleFromDictionary, int row) { var treeItem = new TankTreeItem