From a04a75a8fdc38d5f86eca1b2187b52382e2429f0 Mon Sep 17 00:00:00 2001 From: Jonathan McCaffrey Date: Wed, 13 Apr 2022 23:52:22 -0400 Subject: [PATCH] fix(BuildCalc) Now shows locked entities as gray text. Added some missing data --- .../Parts/HotkeyViewerComponent.razor | 55 ++++++++++--------- Model/Entity/Data/DATA.cs | 37 ++++++++++++- Services/Immortal/EntityFilterService.cs | 15 ++--- 3 files changed, 69 insertions(+), 38 deletions(-) diff --git a/IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor b/IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor index 204b29a..618ef08 100644 --- a/IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor +++ b/IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor @@ -26,11 +26,11 @@ var y = hotkey.PositionY * Size; var border = "1px solid black"; - if (hotkey.KeyText.Equals(_key)) + if (hotkey.KeyText.Equals(key)) { border = "5px solid black"; } - if (hotkey.KeyText.Equals(_controlGroup)) + if (hotkey.KeyText.Equals(controlGroup)) { border = "5px solid green"; } @@ -56,23 +56,30 @@ @hotkey.KeyText @foreach (var entity in data.Values) { - if (buildOrderService.WillMeetRequirements(entity) == null) + + if (InvalidKey(entity, hotkey) || InvalidKeyGroup(entity, hotkey) || InvalidHoldSpace(entity)) { continue; } - if (InvalidKey(entity, hotkey) || InvalidKeyGroup(entity, hotkey) || InvalidHoldSpace(entity)) + if (InvalidFaction(entity)) { continue; } - - if (InvalidFaction(entity) || InvalidVanguard(entity) || InvalidNonVanguard(entity)) + + if (InvalidVanguard(entity) || InvalidNonVanguard(entity)) { continue; } var isVanguard = entity.VanguardAdded() != null; var style = isVanguard ? "font-weight: bold;" : ""; + + if (buildOrderService.WillMeetRequirements(entity) == null) + { + style += "color:gray; font-style: italic;"; + } +
@entity.Info()?.Name
} @@ -110,8 +117,8 @@ readonly Dictionary data = EntityModel.GetDictionary(); readonly List hotkeys = HotkeyModel.GetAll(); - public string _controlGroup = "C"; - public string _key = ""; + private string controlGroup = "C"; + private string key = ""; protected override void OnInitialized() { @@ -211,7 +218,7 @@ bool InvalidKeyGroup(EntityModel entity, HotkeyModel key) { - if (entity.Hotkey()?.HotkeyGroup == _controlGroup) + if (entity.Hotkey()?.HotkeyGroup == controlGroup) { return false; } @@ -221,7 +228,7 @@ bool InvalidKey(EntityModel entity) { - if (entity.Hotkey()?.Hotkey == _key) + if (entity.Hotkey()?.Hotkey == key) { return false; } @@ -230,7 +237,7 @@ bool InvalidKeyGroup(EntityModel entity) { - if (entity.Hotkey()?.HotkeyGroup == _controlGroup) + if (entity.Hotkey()?.HotkeyGroup == controlGroup) { return false; } @@ -249,53 +256,51 @@ void OnKeyPressed() { - string controlGroupWas = _controlGroup; - string keyWas = _key; + string controlGroupWas = controlGroup; + string keyWas = key; if (keyService.GetAllPressedKeys().Contains("Z")) { - _controlGroup = "Z"; + controlGroup = "Z"; } if (keyService.GetAllPressedKeys().Contains("TAB")) { - _controlGroup = "TAB"; + controlGroup = "TAB"; } if (keyService.GetAllPressedKeys().Contains("C")) { - _controlGroup = "C"; + controlGroup = "C"; } if (keyService.GetAllPressedKeys().Contains("D")) { - _controlGroup = "D"; + controlGroup = "D"; } if (keyService.GetAllPressedKeys().Contains("1")) { - _controlGroup = "1"; + controlGroup = "1"; } //TODO This could be better. Duplicated code if (keyService.GetAllPressedKeys().Contains("2")) { - _controlGroup = "2"; + controlGroup = "2"; } if (keyService.GetAllPressedKeys().Contains("SHIFT")) { - _controlGroup = "SHIFT"; + controlGroup = "SHIFT"; } if (keyService.GetAllPressedKeys().Contains("CONTROL")) { - _controlGroup = "CONTROL"; + controlGroup = "CONTROL"; } if (keyService.GetAllPressedKeys().Count > 0) { - _key = keyService.GetAllPressedKeys().First(); + key = keyService.GetAllPressedKeys().First(); } -// HandleClick(); - - if (controlGroupWas != _controlGroup || keyWas != _key) + if (controlGroupWas != controlGroup || keyWas != key) { StateHasChanged(); diff --git a/Model/Entity/Data/DATA.cs b/Model/Entity/Data/DATA.cs index 641c442..0385104 100644 --- a/Model/Entity/Data/DATA.cs +++ b/Model/Entity/Data/DATA.cs @@ -1435,9 +1435,13 @@ public class DATA .AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB" }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityProductionModel { Alloy = 100, Ether = 100, BuildTime = 100 }) + .AddPart(new EntityRequirementModel + { + Id = DataType.BUILDING_Reliquary, + Requirement = RequirementType.Production_Building + }) }, - { DataType.UPGRADE_RadiantWard, new EntityModel(DataType.UPGRADE_RadiantWard, EntityType.Tech) @@ -1449,6 +1453,11 @@ public class DATA .AddPart(new EntityHotkeyModel { Hotkey = "V", HotkeyGroup = "TAB" }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityProductionModel { Alloy = 80, Ether = 80, BuildTime = 34 }) + .AddPart(new EntityRequirementModel + { + Id = DataType.BUILDING_HouseOfFadingSaints, + Requirement = RequirementType.Production_Building + }) }, { @@ -1462,6 +1471,11 @@ public class DATA .AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB", HoldSpace = true}) .AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityProductionModel { Alloy = 100, Ether = 100, BuildTime = 43 }) + .AddPart(new EntityRequirementModel + { + Id = DataType.BUILDING_EyeOfAros, + Requirement = RequirementType.Production_Building + }) }, @@ -1476,6 +1490,8 @@ public class DATA .AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB" }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityProductionModel { Alloy = 50, Ether = 100, BuildTime = 60 }) + .AddPart(new EntityVanguardAddedModel + { ReplaceId = DataType.UPGRADE_GreavesOfAhqar, ImmortalId = DataType.IMMORTAL_Orzum }) }, { @@ -1528,7 +1544,7 @@ public class DATA Name = "Sirocco Script", Descriptive = DescriptiveType.Upgrade, Description = "Grant's the Dervish Sirocco Script" }) - .AddPart(new EntityHotkeyModel { Hotkey = "F", HotkeyGroup = "TAB" }) + .AddPart(new EntityHotkeyModel { Hotkey = "R", HotkeyGroup = "TAB" }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityProductionModel { Alloy = 75, Ether = 100, BuildTime = 60 }) .AddPart(new EntityRequirementModel @@ -1553,6 +1569,10 @@ public class DATA Id = DataType.BUILDING_EyeOfAros, Requirement = RequirementType.Production_Building }) + .AddPart(new EntityVanguardAddedModel + { ReplaceId = DataType.UPGRADE_FortifiedIcons, ImmortalId = DataType.IMMORTAL_Orzum }) + + }, { DataType.UPGRADE_BladesOfTheGodhead, @@ -1735,6 +1755,9 @@ public class DATA Requirement = RequirementType.Research_Building }) .AddPart(new EntityProductionModel { Alloy = 100, Ether = 80, BuildTime = 60 }) + .AddPart(new EntityVanguardAddedModel + { ReplaceId = DataType.UPGRADE_Offering, ImmortalId = DataType.IMMORTAL_Xol }) + }, { @@ -1748,12 +1771,14 @@ public class DATA }) .AddPart(new EntityHotkeyModel { Hotkey = "V", HotkeyGroup = "TAB", HoldSpace = false }) .AddPart(new EntityFactionModel { Faction = FactionType.Aru }) + .AddPart(new EntityProductionModel { Alloy = 100, Ether = 125, BuildTime = 80 }) .AddPart(new EntityRequirementModel { Id = DataType.BUILDING_RedVale, Requirement = RequirementType.Research_Building }) - .AddPart(new EntityProductionModel { Alloy = 100, Ether = 125, BuildTime = 80 }) + .AddPart(new EntityVanguardAddedModel + { ReplaceId = DataType.UPGRADE_BloodMothersFevor, ImmortalId = DataType.IMMORTAL_Xol }) }, @@ -1911,6 +1936,7 @@ public class DATA }) .AddPart(new EntityRequirementModel(){ Id = DataType.UPGRADE_FaithCastBlades, Requirement = RequirementType.Research_Upgrade}) .AddPart(new EntityFactionModel { Faction = FactionType.QRath }) + }, { @@ -2329,6 +2355,11 @@ public class DATA .AddPart(new EntityProductionModel { DefensiveLayer = 30, Cooldown = 40} ) .AddPart(new EntityRequirementModel { Id = DataType.UPGRADE_RadiantWard }) .AddPart(new EntityVitalityModel {Health = 30, DefenseLayer = 30, Lasts = 30, Armor = ArmorType.Light, IsStructure = true}) + .AddPart(new EntityRequirementModel + { + Id = DataType.BUILDING_HouseOfFadingSaints, + Requirement = RequirementType.Production_Building + }) }, { diff --git a/Services/Immortal/EntityFilterService.cs b/Services/Immortal/EntityFilterService.cs index 21770bd..da02615 100644 --- a/Services/Immortal/EntityFilterService.cs +++ b/Services/Immortal/EntityFilterService.cs @@ -20,19 +20,20 @@ public class EntityFilterService : IEntityFilterService { private string _searchText = ""; private string _selectedFaction = FactionType.Any; private string _selectedImmortal = ImmortalType.Any; - + private event EntityFilterAction OnChange = null!; + public EntityFilterService() { RefreshImmortalChoices(); RefreshEntityChoices(); } public void Subscribe(EntityFilterAction action) { - _onChange += action; + OnChange += action; } public void Unsubscribe(EntityFilterAction action) { - _onChange -= action; + OnChange -= action; } public string GetEntityType() { @@ -159,14 +160,8 @@ public class EntityFilterService : IEntityFilterService { } - private event EntityFilterAction _onChange = null!; - private void NotifyDataChanged(EntityFilterEvent entityFilterEvent) { - _onChange?.Invoke(entityFilterEvent); - } - - public EntityFilterAction OnChange() { - return _onChange; + OnChange?.Invoke(entityFilterEvent); } public void Subscribe(Action action) {