diff --git a/Pages/Dialog/EntityDialogComponent.razor b/Pages/Dialog/EntityDialogComponent.razor index d0d5ef4..90c323b 100644 --- a/Pages/Dialog/EntityDialogComponent.razor +++ b/Pages/Dialog/EntityDialogComponent.razor @@ -157,7 +157,7 @@ void OnUpdate() { - entity = EntityData.Get()[entityDialogService.GetEntityId()]; + entity = EntityData.Get()[entityDialogService.GetEntityId() ?? string.Empty]; refresh++; StateHasChanged(); diff --git a/Pages/Dialog/SearchDialogComponent.razor b/Pages/Dialog/SearchDialogComponent.razor index a3fa8ac..52ac374 100644 --- a/Pages/Dialog/SearchDialogComponent.razor +++ b/Pages/Dialog/SearchDialogComponent.razor @@ -135,8 +135,6 @@ @code { - private ElementReference searchBox; - private string SearchText { get; set; } = ""; protected override void OnInitialized() diff --git a/Pages/Pages/BuildCalculator/Parts/ArmyComponent.razor b/Pages/Pages/BuildCalculator/Parts/ArmyComponent.razor index 95c515f..a4f6aff 100644 --- a/Pages/Pages/BuildCalculator/Parts/ArmyComponent.razor +++ b/Pages/Pages/BuildCalculator/Parts/ArmyComponent.razor @@ -131,9 +131,10 @@ armyCount[entity.Info().Name]++; } - if (entity.Production() != null && entity.Production().BuildTime + entitiesAtTime.Key > lastInterval) + var production = entity.Production(); + if (production != null && production.BuildTime + entitiesAtTime.Key > lastInterval) { - lastInterval = entity.Production().BuildTime + entitiesAtTime.Key; + lastInterval = production.BuildTime + entitiesAtTime.Key; } } } diff --git a/Pages/Pages/BuildCalculator/Parts/BankComponent.razor b/Pages/Pages/BuildCalculator/Parts/BankComponent.razor index 2f50693..47636be 100644 --- a/Pages/Pages/BuildCalculator/Parts/BankComponent.razor +++ b/Pages/Pages/BuildCalculator/Parts/BankComponent.razor @@ -110,15 +110,17 @@ _supplyTaken = (from ordersAtInterval in ordersOverTime from order in ordersAtInterval.Value - where order.Supply() != null - where order.Supply().Takes > 0 - select order.Supply().Takes).Sum(); + let supply = order.Supply() + where supply != null + where supply.Takes > 0 + select supply.Takes).Sum(); _supplyGranted = (from ordersAtInterval in ordersOverTime from order in ordersAtInterval.Value - where order.Supply() != null - where order.Supply().Grants > 0 - select order.Supply().Grants).Sum(); + let supply = order.Supply() + where supply != null + where supply.Grants > 0 + select supply.Grants).Sum(); _extraBuildings = 0; if (_supplyGranted > 160) diff --git a/Pages/Pages/BuildCalculator/Parts/BuildChartComponent.razor b/Pages/Pages/BuildCalculator/Parts/BuildChartComponent.razor index 2669314..0fa9458 100644 --- a/Pages/Pages/BuildCalculator/Parts/BuildChartComponent.razor +++ b/Pages/Pages/BuildCalculator/Parts/BuildChartComponent.razor @@ -205,7 +205,9 @@ else var armyValue = 0; foreach (var unit in army) { - armyValue += unit.Production().Alloy + unit.Production().Ether; + var unitProduction = unit.Production(); + if (unitProduction != null) + armyValue += unitProduction.Alloy + unitProduction.Ether; } diff --git a/Pages/Pages/Database/DatabasePage.razor b/Pages/Pages/Database/DatabasePage.razor index 78be906..ebeab2d 100644 --- a/Pages/Pages/Database/DatabasePage.razor +++ b/Pages/Pages/Database/DatabasePage.razor @@ -202,7 +202,8 @@ else { immortals = (from entity in factions - where entity.VanguardAdded() == null || entity.VanguardAdded().ImmortalId == selectedImmortalType + let vanguardAdded = entity.VanguardAdded() + where vanguardAdded == null || vanguardAdded.ImmortalId == selectedImmortalType select entity).ToList(); } diff --git a/Pages/Pages/Database/Entity/Parts/EntityProductionComponent.razor b/Pages/Pages/Database/Entity/Parts/EntityProductionComponent.razor index 84a69ea..f07b761 100644 --- a/Pages/Pages/Database/Entity/Parts/EntityProductionComponent.razor +++ b/Pages/Pages/Database/Entity/Parts/EntityProductionComponent.razor @@ -211,9 +211,9 @@ [CascadingParameter] public string StyleType { get; set; } = "Detailed"; - private EntityProductionModel Production => Entity!.Production(); + private EntityProductionModel? Production => Entity!.Production(); private List Requirements => Entity!.Requirements(); - private EntitySupplyModel Supply => Entity!.Supply(); + private EntitySupplyModel? Supply => Entity!.Supply(); protected override void OnParametersSet() diff --git a/Pages/Pages/Database/Entity/Parts/EntityVanguardsComponent.razor b/Pages/Pages/Database/Entity/Parts/EntityVanguardsComponent.razor index 260970b..e4a4ac1 100644 --- a/Pages/Pages/Database/Entity/Parts/EntityVanguardsComponent.razor +++ b/Pages/Pages/Database/Entity/Parts/EntityVanguardsComponent.razor @@ -38,6 +38,7 @@ var requirements = entity.Requirements(); var vanguard = entity.VanguardAdded(); + if (vanguard == null) continue; var productionBuilding = (from building in requirements where building.Requirement == RequirementType.Production_Building select building).First().Id; diff --git a/Pages/Pages/EconomyComparison/Parts/ChartComponent.razor b/Pages/Pages/EconomyComparison/Parts/ChartComponent.razor index 4902908..354caa6 100644 --- a/Pages/Pages/EconomyComparison/Parts/ChartComponent.razor +++ b/Pages/Pages/EconomyComparison/Parts/ChartComponent.razor @@ -71,8 +71,6 @@ } - int lastRequestedRefreshIndex; - void IDisposable.Dispose() { economyComparisonService.Unsubscribe(OnBuilderOrderChanged); diff --git a/Pages/Pages/StoragePage.razor b/Pages/Pages/StoragePage.razor index ae36c67..f3f8b39 100644 --- a/Pages/Pages/StoragePage.razor +++ b/Pages/Pages/StoragePage.razor @@ -168,8 +168,8 @@ private string? _faction; private string? _immortal; - private string? Faction => _faction == null ? DataType.FACTION_QRath : _faction; - private string? Immortal => _immortal == null ? DataType.IMMORTAL_Orzum : _immortal; + private string Faction => _faction ?? DataType.FACTION_QRath; + private string Immortal => _immortal ?? DataType.IMMORTAL_Orzum; private int? _buildingInputDelay; diff --git a/Pages/Portals/SearchPortal.razor b/Pages/Portals/SearchPortal.razor index 7a5758a..fe6bf4d 100644 --- a/Pages/Portals/SearchPortal.razor +++ b/Pages/Portals/SearchPortal.razor @@ -6,8 +6,6 @@ @code { - private string test = "Q"; - protected override void OnInitialized() { searchService.Subscribe(OnUpdate); diff --git a/Services/Immortal/BuildOrderService.cs b/Services/Immortal/BuildOrderService.cs index e503d21..746659a 100644 --- a/Services/Immortal/BuildOrderService.cs +++ b/Services/Immortal/BuildOrderService.cs @@ -290,15 +290,14 @@ public class BuildOrderService : IBuildOrderService { return (from ordersAtTime in _buildOrder.StartedOrders from orders in ordersAtTime.Value - where orders.Harvest() != null - where ordersAtTime.Key + (orders.Production() == null - ? 0 - : orders.Production().BuildTime) <= interval - && !orders.Harvest().IsDepleted( + let production = orders.Production() + let harvest = orders.Harvest() + where harvest != null + let buildTime = production?.BuildTime ?? 0 + where ordersAtTime.Key + buildTime <= interval + && !harvest.IsDepleted( interval, - ordersAtTime.Key + (orders.Production() == null - ? 0 - : orders.Production().BuildTime)) + ordersAtTime.Key + buildTime) select orders).ToList(); } diff --git a/Services/Immortal/EconomyService.cs b/Services/Immortal/EconomyService.cs index 0e69eac..ebdd32c 100644 --- a/Services/Immortal/EconomyService.cs +++ b/Services/Immortal/EconomyService.cs @@ -11,7 +11,7 @@ public class EconomyService : IEconomyService public List GetOverTime() { - return buildEconomyOverTime; + return buildEconomyOverTime ?? []; } public void Subscribe(Action action) @@ -67,6 +67,7 @@ public class EconomyService : IEconomyService public EconomyModel GetEconomy(int atInterval) { + if (buildEconomyOverTime == null) return new EconomyModel(); return atInterval >= buildEconomyOverTime.Count ? buildEconomyOverTime.Last() : buildEconomyOverTime[atInterval]; @@ -218,7 +219,7 @@ public class EconomyService : IEconomyService private void CarryOverEconomyFromPreviousInterval(int interval, EconomyModel economyAtSecond) { - if (interval <= 0) return; + if (interval <= 0 || buildEconomyOverTime == null) return; economyAtSecond.Alloy = buildEconomyOverTime[interval - 1].Alloy; economyAtSecond.Ether = buildEconomyOverTime[interval - 1].Ether; diff --git a/Services/Website/MyDialogService.cs b/Services/Website/MyDialogService.cs index 6fc5a59..33b20ac 100644 --- a/Services/Website/MyDialogService.cs +++ b/Services/Website/MyDialogService.cs @@ -4,16 +4,16 @@ namespace Services.Website; public class DialogContents { - public string Title { get; set; } - public string Message { get; set; } - public string ConfirmButtonLabel { get; set; } + public string Title { get; set; } = string.Empty; + public string Message { get; set; } = string.Empty; + public string ConfirmButtonLabel { get; set; } = string.Empty; public EventCallback OnConfirm { get; set; } public EventCallback OnCancel { get; set; } } public class MyDialogService : IMyDialogService { - private DialogContents _dialogContents; + private DialogContents _dialogContents = null!; public bool IsVisible { get; set; } diff --git a/Services/Website/PermissionService.cs b/Services/Website/PermissionService.cs index 59e48c2..d9e867f 100644 --- a/Services/Website/PermissionService.cs +++ b/Services/Website/PermissionService.cs @@ -7,8 +7,7 @@ public class PermissionService : IPermissionService, IDisposable private readonly IStorageService _storageService; private IJSRuntime _jsRuntime; private IToastService _toastService; - private bool isLoaded; - private bool isStorageEnabled = false; + public PermissionService(IJSRuntime jsRuntime, IToastService toastService, IStorageService storageService) { diff --git a/Services/Website/StorageService.cs b/Services/Website/StorageService.cs index 298377f..fd73166 100644 --- a/Services/Website/StorageService.cs +++ b/Services/Website/StorageService.cs @@ -50,7 +50,7 @@ public class StorageService : IStorageService public void SetValue(string key, T value) { - if (key.Equals(StorageKeys.EnabledStorage) && value.Equals(true)) + if (value != null && key.Equals(StorageKeys.EnabledStorage) && value.Equals(true)) { _localStorageService.SetItem(key, value); NotifyDataChanged(); diff --git a/Web/PageLayout.razor b/Web/PageLayout.razor index 58189e7..488f497 100644 --- a/Web/PageLayout.razor +++ b/Web/PageLayout.razor @@ -68,7 +68,7 @@ @code { private bool _isDarkMode = true; - private MudThemeProvider _mudThemeProvider; + private MudThemeProvider _mudThemeProvider = null!; bool _drawerOpen = true;