Agent code and restructuring
This commit is contained in:
@@ -282,7 +282,8 @@ public class BuildOrderService : IBuildOrderService
|
||||
{
|
||||
return (from ordersAtTime in _buildOrder.StartedOrders
|
||||
from orders in ordersAtTime.Value
|
||||
where ordersAtTime.Key + (orders.Production() == null ? 0 : orders.Production().BuildTime) <= interval
|
||||
let production = orders.Production()
|
||||
where ordersAtTime.Key + (production?.BuildTime ?? 0) <= interval
|
||||
select orders).ToList();
|
||||
}
|
||||
|
||||
@@ -290,15 +291,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();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class EconomyService : IEconomyService
|
||||
|
||||
public List<EconomyModel> 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;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0-preview.1"/>
|
||||
<PackageReference Include="Microsoft.JSInterop" Version="8.0.14"/>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0"/>
|
||||
<PackageReference Include="Microsoft.JSInterop" Version="10.0.8"/>
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -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<EventArgs> OnConfirm { get; set; }
|
||||
public EventCallback<EventArgs> OnCancel { get; set; }
|
||||
}
|
||||
|
||||
public class MyDialogService : IMyDialogService
|
||||
{
|
||||
private DialogContents _dialogContents;
|
||||
private DialogContents _dialogContents = null!;
|
||||
|
||||
public bool IsVisible { get; set; }
|
||||
|
||||
@@ -24,7 +24,7 @@ public class MyDialogService : IMyDialogService
|
||||
|
||||
public void Unsubscribe(Action action)
|
||||
{
|
||||
OnChange += action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public void Show(DialogContents dialogContents)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SearchService : ISearchService
|
||||
|
||||
public void Unsubscribe(Action action)
|
||||
{
|
||||
OnChange += action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public void Search(string entityId)
|
||||
|
||||
@@ -40,17 +40,17 @@ public class StorageService : IStorageService
|
||||
|
||||
public void Unsubscribe(Action action)
|
||||
{
|
||||
OnChange += action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public T GetValue<T>(string forKey)
|
||||
{
|
||||
return _localStorageService.GetItem<T>(forKey);
|
||||
return _localStorageService.GetItem<T>(forKey)!;
|
||||
}
|
||||
|
||||
public void SetValue<T>(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();
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ToastService : IToastService
|
||||
|
||||
public void Unsubscribe(Action action)
|
||||
{
|
||||
OnChange += action;
|
||||
OnChange -= action;
|
||||
}
|
||||
|
||||
public void AddToast(ToastModel toast)
|
||||
|
||||
Reference in New Issue
Block a user