Browse Source

fix(BuildCalc) Now shows locked entities as gray text. Added some missing data

main
Jonathan McCaffrey 4 years ago
parent
commit
a04a75a8fd
  1. 53
      IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor
  2. 37
      Model/Entity/Data/DATA.cs
  3. 13
      Services/Immortal/EntityFilterService.cs

53
IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor

@ -26,11 +26,11 @@
var y = hotkey.PositionY * Size; var y = hotkey.PositionY * Size;
var border = "1px solid black"; var border = "1px solid black";
if (hotkey.KeyText.Equals(_key)) if (hotkey.KeyText.Equals(key))
{ {
border = "5px solid black"; border = "5px solid black";
} }
if (hotkey.KeyText.Equals(_controlGroup)) if (hotkey.KeyText.Equals(controlGroup))
{ {
border = "5px solid green"; border = "5px solid green";
} }
@ -56,17 +56,18 @@
@hotkey.KeyText @hotkey.KeyText
@foreach (var entity in data.Values) @foreach (var entity in data.Values)
{ {
if (buildOrderService.WillMeetRequirements(entity) == null)
if (InvalidKey(entity, hotkey) || InvalidKeyGroup(entity, hotkey) || InvalidHoldSpace(entity))
{ {
continue; continue;
} }
if (InvalidKey(entity, hotkey) || InvalidKeyGroup(entity, hotkey) || InvalidHoldSpace(entity)) if (InvalidFaction(entity))
{ {
continue; continue;
} }
if (InvalidFaction(entity) || InvalidVanguard(entity) || InvalidNonVanguard(entity)) if (InvalidVanguard(entity) || InvalidNonVanguard(entity))
{ {
continue; continue;
} }
@ -74,6 +75,12 @@
var isVanguard = entity.VanguardAdded() != null; var isVanguard = entity.VanguardAdded() != null;
var style = isVanguard ? "font-weight: bold;" : ""; var style = isVanguard ? "font-weight: bold;" : "";
if (buildOrderService.WillMeetRequirements(entity) == null)
{
style += "color:gray; font-style: italic;";
}
<div style="@style">@entity.Info()?.Name</div> <div style="@style">@entity.Info()?.Name</div>
} }
</div> </div>
@ -110,8 +117,8 @@
readonly Dictionary<string, EntityModel> data = EntityModel.GetDictionary(); readonly Dictionary<string, EntityModel> data = EntityModel.GetDictionary();
readonly List<HotkeyModel> hotkeys = HotkeyModel.GetAll(); readonly List<HotkeyModel> hotkeys = HotkeyModel.GetAll();
public string _controlGroup = "C"; private string controlGroup = "C";
public string _key = ""; private string key = "";
protected override void OnInitialized() protected override void OnInitialized()
{ {
@ -211,7 +218,7 @@
bool InvalidKeyGroup(EntityModel entity, HotkeyModel key) bool InvalidKeyGroup(EntityModel entity, HotkeyModel key)
{ {
if (entity.Hotkey()?.HotkeyGroup == _controlGroup) if (entity.Hotkey()?.HotkeyGroup == controlGroup)
{ {
return false; return false;
} }
@ -221,7 +228,7 @@
bool InvalidKey(EntityModel entity) bool InvalidKey(EntityModel entity)
{ {
if (entity.Hotkey()?.Hotkey == _key) if (entity.Hotkey()?.Hotkey == key)
{ {
return false; return false;
} }
@ -230,7 +237,7 @@
bool InvalidKeyGroup(EntityModel entity) bool InvalidKeyGroup(EntityModel entity)
{ {
if (entity.Hotkey()?.HotkeyGroup == _controlGroup) if (entity.Hotkey()?.HotkeyGroup == controlGroup)
{ {
return false; return false;
} }
@ -249,53 +256,51 @@
void OnKeyPressed() void OnKeyPressed()
{ {
string controlGroupWas = _controlGroup; string controlGroupWas = controlGroup;
string keyWas = _key; string keyWas = key;
if (keyService.GetAllPressedKeys().Contains("Z")) if (keyService.GetAllPressedKeys().Contains("Z"))
{ {
_controlGroup = "Z"; controlGroup = "Z";
} }
if (keyService.GetAllPressedKeys().Contains("TAB")) if (keyService.GetAllPressedKeys().Contains("TAB"))
{ {
_controlGroup = "TAB"; controlGroup = "TAB";
} }
if (keyService.GetAllPressedKeys().Contains("C")) if (keyService.GetAllPressedKeys().Contains("C"))
{ {
_controlGroup = "C"; controlGroup = "C";
} }
if (keyService.GetAllPressedKeys().Contains("D")) if (keyService.GetAllPressedKeys().Contains("D"))
{ {
_controlGroup = "D"; controlGroup = "D";
} }
if (keyService.GetAllPressedKeys().Contains("1")) if (keyService.GetAllPressedKeys().Contains("1"))
{ {
_controlGroup = "1"; controlGroup = "1";
} }
//TODO This could be better. Duplicated code //TODO This could be better. Duplicated code
if (keyService.GetAllPressedKeys().Contains("2")) if (keyService.GetAllPressedKeys().Contains("2"))
{ {
_controlGroup = "2"; controlGroup = "2";
} }
if (keyService.GetAllPressedKeys().Contains("SHIFT")) if (keyService.GetAllPressedKeys().Contains("SHIFT"))
{ {
_controlGroup = "SHIFT"; controlGroup = "SHIFT";
} }
if (keyService.GetAllPressedKeys().Contains("CONTROL")) if (keyService.GetAllPressedKeys().Contains("CONTROL"))
{ {
_controlGroup = "CONTROL"; controlGroup = "CONTROL";
} }
if (keyService.GetAllPressedKeys().Count > 0) 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(); StateHasChanged();

37
Model/Entity/Data/DATA.cs

@ -1435,9 +1435,13 @@ public class DATA
.AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB" }) .AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB" })
.AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 100, Ether = 100, BuildTime = 100 }) .AddPart(new EntityProductionModel { Alloy = 100, Ether = 100, BuildTime = 100 })
.AddPart(new EntityRequirementModel
{
Id = DataType.BUILDING_Reliquary,
Requirement = RequirementType.Production_Building
})
}, },
{ {
DataType.UPGRADE_RadiantWard, DataType.UPGRADE_RadiantWard,
new EntityModel(DataType.UPGRADE_RadiantWard, EntityType.Tech) new EntityModel(DataType.UPGRADE_RadiantWard, EntityType.Tech)
@ -1449,6 +1453,11 @@ public class DATA
.AddPart(new EntityHotkeyModel { Hotkey = "V", HotkeyGroup = "TAB" }) .AddPart(new EntityHotkeyModel { Hotkey = "V", HotkeyGroup = "TAB" })
.AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 80, Ether = 80, BuildTime = 34 }) .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 EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB", HoldSpace = true})
.AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 100, Ether = 100, BuildTime = 43 }) .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 EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB" })
.AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 50, Ether = 100, BuildTime = 60 }) .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, Name = "Sirocco Script", Descriptive = DescriptiveType.Upgrade,
Description = "Grant's the Dervish Sirocco Script" 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 EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 75, Ether = 100, BuildTime = 60 }) .AddPart(new EntityProductionModel { Alloy = 75, Ether = 100, BuildTime = 60 })
.AddPart(new EntityRequirementModel .AddPart(new EntityRequirementModel
@ -1553,6 +1569,10 @@ public class DATA
Id = DataType.BUILDING_EyeOfAros, Id = DataType.BUILDING_EyeOfAros,
Requirement = RequirementType.Production_Building Requirement = RequirementType.Production_Building
}) })
.AddPart(new EntityVanguardAddedModel
{ ReplaceId = DataType.UPGRADE_FortifiedIcons, ImmortalId = DataType.IMMORTAL_Orzum })
}, },
{ {
DataType.UPGRADE_BladesOfTheGodhead, DataType.UPGRADE_BladesOfTheGodhead,
@ -1735,6 +1755,9 @@ public class DATA
Requirement = RequirementType.Research_Building Requirement = RequirementType.Research_Building
}) })
.AddPart(new EntityProductionModel { Alloy = 100, Ether = 80, BuildTime = 60 }) .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 EntityHotkeyModel { Hotkey = "V", HotkeyGroup = "TAB", HoldSpace = false })
.AddPart(new EntityFactionModel { Faction = FactionType.Aru }) .AddPart(new EntityFactionModel { Faction = FactionType.Aru })
.AddPart(new EntityProductionModel { Alloy = 100, Ether = 125, BuildTime = 80 })
.AddPart(new EntityRequirementModel .AddPart(new EntityRequirementModel
{ {
Id = DataType.BUILDING_RedVale, Id = DataType.BUILDING_RedVale,
Requirement = RequirementType.Research_Building 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 EntityRequirementModel(){ Id = DataType.UPGRADE_FaithCastBlades, Requirement = RequirementType.Research_Upgrade})
.AddPart(new EntityFactionModel { Faction = FactionType.QRath }) .AddPart(new EntityFactionModel { Faction = FactionType.QRath })
}, },
{ {
@ -2329,6 +2355,11 @@ public class DATA
.AddPart(new EntityProductionModel { DefensiveLayer = 30, Cooldown = 40} ) .AddPart(new EntityProductionModel { DefensiveLayer = 30, Cooldown = 40} )
.AddPart(new EntityRequirementModel { Id = DataType.UPGRADE_RadiantWard }) .AddPart(new EntityRequirementModel { Id = DataType.UPGRADE_RadiantWard })
.AddPart(new EntityVitalityModel {Health = 30, DefenseLayer = 30, Lasts = 30, Armor = ArmorType.Light, IsStructure = true}) .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
})
}, },
{ {

13
Services/Immortal/EntityFilterService.cs

@ -21,6 +21,7 @@ public class EntityFilterService : IEntityFilterService {
private string _selectedFaction = FactionType.Any; private string _selectedFaction = FactionType.Any;
private string _selectedImmortal = ImmortalType.Any; private string _selectedImmortal = ImmortalType.Any;
private event EntityFilterAction OnChange = null!;
public EntityFilterService() { public EntityFilterService() {
RefreshImmortalChoices(); RefreshImmortalChoices();
@ -28,11 +29,11 @@ public class EntityFilterService : IEntityFilterService {
} }
public void Subscribe(EntityFilterAction action) { public void Subscribe(EntityFilterAction action) {
_onChange += action; OnChange += action;
} }
public void Unsubscribe(EntityFilterAction action) { public void Unsubscribe(EntityFilterAction action) {
_onChange -= action; OnChange -= action;
} }
public string GetEntityType() { public string GetEntityType() {
@ -159,14 +160,8 @@ public class EntityFilterService : IEntityFilterService {
} }
private event EntityFilterAction _onChange = null!;
private void NotifyDataChanged(EntityFilterEvent entityFilterEvent) { private void NotifyDataChanged(EntityFilterEvent entityFilterEvent) {
_onChange?.Invoke(entityFilterEvent); OnChange?.Invoke(entityFilterEvent);
}
public EntityFilterAction OnChange() {
return _onChange;
} }
public void Subscribe(Action action) { public void Subscribe(Action action) {

Loading…
Cancel
Save