Unfinished training queue code
This commit is contained in:
@@ -15,24 +15,24 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<SupportedPlatform Include="browser"/>
|
||||
<SupportedPlatform Include="browser" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Markdig" Version="0.28.1"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0-preview.2.22153.2"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.0-preview.2.22153.2"/>
|
||||
<PackageReference Include="Markdig" Version="0.30.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0-preview.3.22178.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.0-preview.3.22178.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Inputs\"/>
|
||||
<Folder Include="Inputs\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Model\Model.csproj"/>
|
||||
<ProjectReference Include="..\Services\Services.csproj"/>
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
<ProjectReference Include="..\Services\Services.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Inputs\"/>
|
||||
<None Remove="Inputs\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-preview.2.22153.1"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0-preview.2.22153.1">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-preview.3.22175.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0-preview.3.22175.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Model\Model.csproj"/>
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Binary file not shown.
+4
-4
@@ -20,10 +20,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Markdig" Version="0.28.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0-preview.2.22153.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0-preview.2.22153.2" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.0-preview.2.22153.2" />
|
||||
<PackageReference Include="Markdig" Version="0.30.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0-preview.3.22178.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0-preview.3.22178.4" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.0-preview.3.22178.4" />
|
||||
<!--
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0-preview.2.22153.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.0-preview.2.22153.1" />
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
@layout PageLayout
|
||||
|
||||
<DevOnlyComponent>
|
||||
<HarassCalculatorPage></HarassCalculatorPage>
|
||||
<BuildCalculatorPage></BuildCalculatorPage>
|
||||
</DevOnlyComponent>
|
||||
|
||||
<HomePage/>
|
||||
@@ -11,18 +11,18 @@
|
||||
</FormDisplayComponent>
|
||||
<div class="bankRow">
|
||||
<FormDisplayComponent Label="Alloy">
|
||||
<Display>@economy.Alloy</Display>
|
||||
<Display>@_economy.Alloy</Display>
|
||||
</FormDisplayComponent>
|
||||
<FormDisplayComponent Label="Ether">
|
||||
<Display>@economy.Ether</Display>
|
||||
<Display>@_economy.Ether</Display>
|
||||
</FormDisplayComponent>
|
||||
</div>
|
||||
<div class="bankRow">
|
||||
<FormDisplayComponent Label="Pyre">
|
||||
<Display>@economy.Pyre</Display>
|
||||
<Display>@_economy.Pyre</Display>
|
||||
</FormDisplayComponent>
|
||||
<FormDisplayComponent Label="Supply">
|
||||
<Display>@supplyTaken / @supplyGranted (@(supplyGranted / 16)@(extraBuildings > 0 ? "+" + extraBuildings : ""))</Display>
|
||||
<Display>@_supplyTaken / @_supplyGranted (@(_supplyGranted / 16)@(_extraBuildings > 0 ? "+" + _extraBuildings : ""))</Display>
|
||||
</FormDisplayComponent>
|
||||
</div>
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
<div class="workerText">Workers</div>
|
||||
<div class="bankRow">
|
||||
<FormDisplayComponent Label="Current">
|
||||
<Display>@economy.WorkerCount</Display>
|
||||
<Display>@_economy.WorkerCount</Display>
|
||||
</FormDisplayComponent>
|
||||
<FormDisplayComponent Label="Busy">
|
||||
<Display>@economy.BusyWorkerCount</Display>
|
||||
<Display>@_economy.BusyWorkerCount</Display>
|
||||
</FormDisplayComponent>
|
||||
<FormDisplayComponent Label="Creating">
|
||||
<Display>@economy.CreatingWorkerCount</Display>
|
||||
<Display>@_economy.CreatingWorkerCount</Display>
|
||||
</FormDisplayComponent>
|
||||
</div>
|
||||
</div>
|
||||
@@ -68,10 +68,10 @@
|
||||
[Inject]
|
||||
IEconomyService EconomyService { get; set; } = default!;
|
||||
|
||||
EconomyModel economy = new();
|
||||
int supplyGranted;
|
||||
int supplyTaken;
|
||||
int extraBuildings;
|
||||
EconomyModel _economy = new();
|
||||
int _supplyGranted;
|
||||
int _supplyTaken;
|
||||
int _extraBuildings;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
@@ -101,27 +101,27 @@
|
||||
|
||||
void OnBuildOrderChanged()
|
||||
{
|
||||
economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval());
|
||||
_economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval());
|
||||
|
||||
var ordersOverTime = BuildOrderService.GetOrders();
|
||||
|
||||
supplyTaken = (from ordersAtInterval in ordersOverTime
|
||||
_supplyTaken = (from ordersAtInterval in ordersOverTime
|
||||
from order in ordersAtInterval.Value
|
||||
where order.Supply() != null
|
||||
where order.Supply().Takes > 0
|
||||
select order.Supply().Takes).Sum();
|
||||
|
||||
supplyGranted = (from ordersAtInterval in ordersOverTime
|
||||
_supplyGranted = (from ordersAtInterval in ordersOverTime
|
||||
from order in ordersAtInterval.Value
|
||||
where order.Supply() != null
|
||||
where order.Supply().Grants > 0
|
||||
select order.Supply().Grants).Sum();
|
||||
|
||||
extraBuildings = 0;
|
||||
if (supplyGranted > 160)
|
||||
_extraBuildings = 0;
|
||||
if (_supplyGranted > 160)
|
||||
{
|
||||
extraBuildings = (supplyGranted - 160) / 16;
|
||||
supplyGranted = 160;
|
||||
_extraBuildings = (_supplyGranted - 160) / 16;
|
||||
_supplyGranted = 160;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,49 +1,10 @@
|
||||
@page "/economy-comparison"
|
||||
|
||||
@implements IDisposable
|
||||
@inject IEconomyComparisonService economyComparisonService
|
||||
@inject IEconomyComparisonService EconomyComparisonService
|
||||
@layout PageLayout
|
||||
|
||||
|
||||
<LayoutMediumContentComponent>
|
||||
|
||||
<AlertComponent Type="@SeverityType.Error">
|
||||
<Title>Contains Bugs</Title>
|
||||
<Message>None of these calculations and results have been verified. Use with caution. </Message>
|
||||
</AlertComponent>
|
||||
|
||||
<DevOnlyComponent>
|
||||
@foreach (var buildToCompare in economyComparisonService.BuildsToCompare)
|
||||
{
|
||||
foreach (var ordersAtTime in buildToCompare.BuildOrderModel.StartedOrders)
|
||||
{
|
||||
foreach (var order in ordersAtTime.Value)
|
||||
{
|
||||
<div>@ordersAtTime.Key - @order.Info().Name</div>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@{
|
||||
float alloyHighest = 0;
|
||||
}
|
||||
@foreach (var buildToCompare in economyComparisonService.BuildsToCompare)
|
||||
{
|
||||
foreach (var economy in buildToCompare.EconomyOverTimeModel)
|
||||
{
|
||||
if (economy.Alloy > alloyHighest)
|
||||
{
|
||||
alloyHighest = economy.Alloy;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<div>@alloyHighest</div>
|
||||
|
||||
</DevOnlyComponent>
|
||||
|
||||
<PaperComponent>
|
||||
<div>You</div>
|
||||
<EconomyInputComponent ForPlayer="0"/>
|
||||
@@ -65,7 +26,6 @@
|
||||
<ContentDividerComponent/>
|
||||
|
||||
<PaperComponent>
|
||||
|
||||
<InfoBodyComponent>
|
||||
<InfoQuestionComponent>
|
||||
What is this tool for?
|
||||
@@ -78,18 +38,13 @@
|
||||
</LayoutMediumContentComponent>
|
||||
|
||||
@code {
|
||||
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
economyComparisonService.Subscribe(StateHasChanged);
|
||||
|
||||
EconomyComparisonService.Subscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
economyComparisonService.Unsubscribe(StateHasChanged);
|
||||
EconomyComparisonService.Unsubscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -8,18 +8,18 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Contexts\Contexts.csproj"/>
|
||||
<ProjectReference Include="..\Model\Model.csproj"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.0-preview.2.22153.1"/>
|
||||
<ProjectReference Include="..\Contexts\Contexts.csproj" />
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.0-preview.3.22175.1" />
|
||||
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-preview.2.22153.1"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0-preview.2.22153.1">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-preview.3.22175.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0-preview.3.22175.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0-preview.2.22153.1"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0-preview.2.22153.1"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0-preview.2.22153.1">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0-preview.3.22175.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0-preview.3.22175.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0-preview.3.22175.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Model.BuildOrders;
|
||||
|
||||
public class TrainingCapacityUsedModel
|
||||
{
|
||||
public int TrainingCapacity { get; set; } = 4;
|
||||
public int UsedSlots { get; set; } = 4;
|
||||
public string UsedBuilding { get; set; } = DataType.BUILDING_LegionHall;
|
||||
public int StartingUsageTime { get; set; } = 30;
|
||||
public int StopUsageTime { get; set; } = 60;
|
||||
|
||||
@@ -12,33 +12,33 @@ namespace Services.Immortal;
|
||||
|
||||
public class BuildOrderService : IBuildOrderService
|
||||
{
|
||||
private readonly BuildOrderModel buildOrder = new();
|
||||
private int lastInterval;
|
||||
private readonly BuildOrderModel _buildOrder = new();
|
||||
|
||||
private readonly IToastService toastService;
|
||||
private readonly IToastService _toastService;
|
||||
private int _lastInterval;
|
||||
|
||||
public BuildOrderService(IToastService toastService)
|
||||
{
|
||||
this.toastService = toastService;
|
||||
_toastService = toastService;
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
public int BuildingInputDelay { get; set; } = 2;
|
||||
|
||||
public Dictionary<int, List<EntityModel>> StartedOrders => buildOrder.StartedOrders;
|
||||
public Dictionary<int, List<EntityModel>> CompletedOrders => buildOrder.CompletedOrders;
|
||||
public Dictionary<string, int> UniqueCompletedTimes => buildOrder.UniqueCompletedTimes;
|
||||
public Dictionary<int, int> SupplyCountTimes => buildOrder.SupplyCountTimes;
|
||||
public Dictionary<int, List<EntityModel>> StartedOrders => _buildOrder.StartedOrders;
|
||||
public Dictionary<int, List<EntityModel>> CompletedOrders => _buildOrder.CompletedOrders;
|
||||
public Dictionary<string, int> UniqueCompletedTimes => _buildOrder.UniqueCompletedTimes;
|
||||
public Dictionary<int, int> SupplyCountTimes => _buildOrder.SupplyCountTimes;
|
||||
|
||||
public int GetLastRequestInterval()
|
||||
{
|
||||
return lastInterval;
|
||||
return _lastInterval;
|
||||
}
|
||||
|
||||
public Dictionary<int, List<EntityModel>> GetOrders()
|
||||
{
|
||||
return buildOrder.StartedOrders;
|
||||
return _buildOrder.StartedOrders;
|
||||
}
|
||||
|
||||
public void Subscribe(Action action)
|
||||
@@ -54,49 +54,52 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
public void Add(EntityModel entity, int atInterval)
|
||||
{
|
||||
if (!buildOrder.StartedOrders.ContainsKey(atInterval))
|
||||
buildOrder.StartedOrders.Add(atInterval, new List<EntityModel>());
|
||||
if (!_buildOrder.StartedOrders.ContainsKey(atInterval))
|
||||
_buildOrder.StartedOrders.Add(atInterval, new List<EntityModel>());
|
||||
|
||||
var production = entity.Production();
|
||||
|
||||
var completedTime = atInterval;
|
||||
if (production != null) completedTime += production.BuildTime;
|
||||
|
||||
if (!buildOrder.CompletedOrders.ContainsKey(completedTime))
|
||||
buildOrder.CompletedOrders.Add(completedTime, new List<EntityModel>());
|
||||
if (!_buildOrder.CompletedOrders.ContainsKey(completedTime))
|
||||
_buildOrder.CompletedOrders.Add(completedTime, new List<EntityModel>());
|
||||
|
||||
var supply = entity.Supply();
|
||||
_buildOrder.StartedOrders[atInterval].Add(entity.Clone());
|
||||
_buildOrder.CompletedOrders[completedTime].Add(entity.Clone());
|
||||
|
||||
if (!_buildOrder.UniqueCompletedTimes.ContainsKey(entity.DataType))
|
||||
_buildOrder.UniqueCompletedTimes.Add(entity.DataType, atInterval);
|
||||
|
||||
buildOrder.StartedOrders[atInterval].Add(entity.Clone());
|
||||
buildOrder.CompletedOrders[completedTime].Add(entity.Clone());
|
||||
|
||||
if (!buildOrder.UniqueCompletedTimes.ContainsKey(entity.DataType))
|
||||
buildOrder.UniqueCompletedTimes.Add(entity.DataType, atInterval);
|
||||
|
||||
if (!buildOrder.UniqueCompletedCount.ContainsKey(entity.DataType))
|
||||
buildOrder.UniqueCompletedCount.Add(entity.DataType, 1);
|
||||
if (!_buildOrder.UniqueCompletedCount.ContainsKey(entity.DataType))
|
||||
_buildOrder.UniqueCompletedCount.Add(entity.DataType, 1);
|
||||
else
|
||||
buildOrder.UniqueCompletedCount[entity.DataType]++;
|
||||
_buildOrder.UniqueCompletedCount[entity.DataType]++;
|
||||
|
||||
//entity.
|
||||
if (!buildOrder.UniqueCompleted.ContainsKey(entity.DataType))
|
||||
buildOrder.UniqueCompleted.Add(entity.DataType, new Dictionary<int, List<EntityModel>>());
|
||||
if (!_buildOrder.UniqueCompleted.ContainsKey(entity.DataType))
|
||||
_buildOrder.UniqueCompleted.Add(entity.DataType, new Dictionary<int, List<EntityModel>>());
|
||||
|
||||
if (!buildOrder.UniqueCompleted[entity.DataType].ContainsKey(completedTime))
|
||||
buildOrder.UniqueCompleted[entity.DataType].Add(completedTime, new List<EntityModel>());
|
||||
if (!_buildOrder.UniqueCompleted[entity.DataType].ContainsKey(completedTime))
|
||||
_buildOrder.UniqueCompleted[entity.DataType].Add(completedTime, new List<EntityModel>());
|
||||
|
||||
buildOrder.UniqueCompleted[entity.DataType][completedTime].Add(entity);
|
||||
|
||||
|
||||
if (supply != null)
|
||||
if (entity.Production()?.ProducedBy != null)
|
||||
_buildOrder.TrainingCapacityUsed.Add(new TrainingCapacityUsedModel
|
||||
{
|
||||
if (!supply.Takes.Equals(0)) buildOrder.CurrentSupplyUsed += supply.Takes;
|
||||
if (!supply.Grants.Equals(0))
|
||||
buildOrder.SupplyCountTimes.Add(buildOrder.SupplyCountTimes.Last().Key + supply.Grants, completedTime);
|
||||
}
|
||||
StartingUsageTime = atInterval,
|
||||
StopUsageTime = completedTime,
|
||||
UsedSlots = entity.Supply() != null ? entity.Supply()!.Takes : 1,
|
||||
UsedBuilding = entity.Production()!.ProducedBy
|
||||
});
|
||||
|
||||
if (atInterval > lastInterval) lastInterval = atInterval;
|
||||
_buildOrder.UniqueCompleted[entity.DataType][completedTime].Add(entity);
|
||||
|
||||
if (entity.Supply() != null && entity.Supply()!.Takes > 0)
|
||||
_buildOrder.CurrentSupplyUsed += entity.Supply()!.Takes;
|
||||
if (entity.Supply() != null && entity.Supply()!.Grants > 0)
|
||||
_buildOrder.SupplyCountTimes.Add(_buildOrder.SupplyCountTimes.Last().Key + entity.Supply()!.Grants,
|
||||
completedTime);
|
||||
|
||||
if (atInterval > _lastInterval) _lastInterval = atInterval;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
@@ -105,17 +108,18 @@ public class BuildOrderService : IBuildOrderService
|
||||
{
|
||||
if (forInterval < 0)
|
||||
{
|
||||
toastService.AddToast(new ToastModel(){SeverityType = SeverityType.Error, Title = "Wait", Message = "This should never happen."});
|
||||
_toastService.AddToast(new ToastModel
|
||||
{ SeverityType = SeverityType.Error, Title = "Wait", Message = "This should never happen." });
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
lastInterval += forInterval;
|
||||
_lastInterval += forInterval;
|
||||
|
||||
if (!buildOrder.StartedOrders.ContainsKey(lastInterval))
|
||||
buildOrder.StartedOrders.Add(lastInterval, new List<EntityModel>());
|
||||
if (!_buildOrder.StartedOrders.ContainsKey(_lastInterval))
|
||||
_buildOrder.StartedOrders.Add(_lastInterval, new List<EntityModel>());
|
||||
|
||||
if (!buildOrder.CompletedOrders.ContainsKey(lastInterval))
|
||||
buildOrder.CompletedOrders.Add(lastInterval, new List<EntityModel>());
|
||||
if (!_buildOrder.CompletedOrders.ContainsKey(_lastInterval))
|
||||
_buildOrder.CompletedOrders.Add(_lastInterval, new List<EntityModel>());
|
||||
|
||||
NotifyDataChanged();
|
||||
return true;
|
||||
@@ -123,19 +127,23 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
public bool AddWaitTo(int interval)
|
||||
{
|
||||
if (interval <= lastInterval)
|
||||
if (interval <= _lastInterval)
|
||||
{
|
||||
toastService.AddToast(new ToastModel(){SeverityType = SeverityType.Error, Title = "Logic Error", Message = "You cannot wait to a time that has already elapsed."});
|
||||
_toastService.AddToast(new ToastModel
|
||||
{
|
||||
SeverityType = SeverityType.Error, Title = "Logic Error",
|
||||
Message = "You cannot wait to a time that has already elapsed."
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
lastInterval = interval;
|
||||
_lastInterval = interval;
|
||||
|
||||
if (!buildOrder.StartedOrders.ContainsKey(lastInterval))
|
||||
buildOrder.StartedOrders.Add(lastInterval, new List<EntityModel>());
|
||||
if (!_buildOrder.StartedOrders.ContainsKey(_lastInterval))
|
||||
_buildOrder.StartedOrders.Add(_lastInterval, new List<EntityModel>());
|
||||
|
||||
if (!buildOrder.CompletedOrders.ContainsKey(lastInterval))
|
||||
buildOrder.CompletedOrders.Add(lastInterval, new List<EntityModel>());
|
||||
if (!_buildOrder.CompletedOrders.ContainsKey(_lastInterval))
|
||||
_buildOrder.CompletedOrders.Add(_lastInterval, new List<EntityModel>());
|
||||
|
||||
NotifyDataChanged();
|
||||
return true;
|
||||
@@ -149,7 +157,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
var metTime = 0;
|
||||
foreach (var requiredEntity in requirements)
|
||||
if (buildOrder.UniqueCompletedTimes.TryGetValue(requiredEntity.Id, out var completedTime))
|
||||
if (_buildOrder.UniqueCompletedTimes.TryGetValue(requiredEntity.Id, out var completedTime))
|
||||
{
|
||||
if (completedTime > metTime) metTime = completedTime;
|
||||
}
|
||||
@@ -167,8 +175,8 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
if (supply == null || supply.Takes.Equals(0)) return 0;
|
||||
|
||||
foreach (var supplyAtTime in buildOrder.SupplyCountTimes)
|
||||
if (supply.Takes + buildOrder.CurrentSupplyUsed < supplyAtTime.Key)
|
||||
foreach (var supplyAtTime in _buildOrder.SupplyCountTimes)
|
||||
if (supply.Takes + _buildOrder.CurrentSupplyUsed <= supplyAtTime.Key)
|
||||
return supplyAtTime.Value;
|
||||
|
||||
return null;
|
||||
@@ -177,7 +185,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
public bool Add(EntityModel entity, IEconomyService withEconomy)
|
||||
{
|
||||
var atInterval = lastInterval;
|
||||
var atInterval = _lastInterval;
|
||||
|
||||
if (!HandleSupply(entity, ref atInterval)) return false;
|
||||
if (!HandleRequirements(entity, ref atInterval)) return false;
|
||||
@@ -190,47 +198,47 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
public void RemoveLast()
|
||||
{
|
||||
if (buildOrder.StartedOrders.Keys.Count > 1)
|
||||
if (_buildOrder.StartedOrders.Keys.Count > 1)
|
||||
{
|
||||
if (buildOrder.StartedOrders.Count == 0)
|
||||
if (_buildOrder.StartedOrders.Count == 0)
|
||||
{
|
||||
buildOrder.StartedOrders.Remove(buildOrder.StartedOrders.Last().Key);
|
||||
buildOrder.CompletedOrders.Remove(buildOrder.CompletedOrders.Last().Key);
|
||||
_buildOrder.StartedOrders.Remove(_buildOrder.StartedOrders.Last().Key);
|
||||
_buildOrder.CompletedOrders.Remove(_buildOrder.CompletedOrders.Last().Key);
|
||||
|
||||
lastInterval = buildOrder.StartedOrders.Last().Key;
|
||||
_lastInterval = _buildOrder.StartedOrders.Last().Key;
|
||||
return;
|
||||
}
|
||||
|
||||
var lastStarted = buildOrder.StartedOrders.Keys.Last();
|
||||
var lastCompleted = buildOrder.CompletedOrders.Keys.Last();
|
||||
var lastStarted = _buildOrder.StartedOrders.Keys.Last();
|
||||
var lastCompleted = _buildOrder.CompletedOrders.Keys.Last();
|
||||
|
||||
EntityModel entityRemoved = default!;
|
||||
|
||||
if (buildOrder.StartedOrders[lastStarted].Count > 0)
|
||||
if (_buildOrder.StartedOrders[lastStarted].Count > 0)
|
||||
{
|
||||
entityRemoved = buildOrder.StartedOrders[lastStarted].Last();
|
||||
buildOrder.StartedOrders[lastStarted].Remove(buildOrder.StartedOrders[lastStarted].Last());
|
||||
buildOrder.CompletedOrders[lastCompleted].Remove(buildOrder.CompletedOrders[lastCompleted].Last());
|
||||
entityRemoved = _buildOrder.StartedOrders[lastStarted].Last();
|
||||
_buildOrder.StartedOrders[lastStarted].Remove(_buildOrder.StartedOrders[lastStarted].Last());
|
||||
_buildOrder.CompletedOrders[lastCompleted].Remove(_buildOrder.CompletedOrders[lastCompleted].Last());
|
||||
}
|
||||
|
||||
if (buildOrder.StartedOrders[lastStarted].Count == 0) buildOrder.StartedOrders.Remove(lastStarted);
|
||||
if (buildOrder.CompletedOrders[lastCompleted].Count == 0) buildOrder.CompletedOrders.Remove(lastCompleted);
|
||||
if (_buildOrder.StartedOrders[lastStarted].Count == 0) _buildOrder.StartedOrders.Remove(lastStarted);
|
||||
if (_buildOrder.CompletedOrders[lastCompleted].Count == 0)
|
||||
_buildOrder.CompletedOrders.Remove(lastCompleted);
|
||||
|
||||
if (buildOrder.StartedOrders.Keys.Count > 0)
|
||||
lastInterval = buildOrder.StartedOrders.Keys.Last();
|
||||
if (_buildOrder.StartedOrders.Keys.Count > 0)
|
||||
_lastInterval = _buildOrder.StartedOrders.Keys.Last();
|
||||
else
|
||||
lastInterval = 0;
|
||||
_lastInterval = 0;
|
||||
|
||||
if (entityRemoved.Supply()?.Grants > 0)
|
||||
SupplyCountTimes.Remove(SupplyCountTimes.Last().Key);
|
||||
|
||||
if (entityRemoved.Supply()?.Takes > 0)
|
||||
buildOrder.CurrentSupplyUsed -= entityRemoved.Supply()!.Takes;
|
||||
_buildOrder.CurrentSupplyUsed -= entityRemoved.Supply()!.Takes;
|
||||
|
||||
|
||||
|
||||
buildOrder.UniqueCompletedCount[entityRemoved!.DataType]--;
|
||||
if (buildOrder.UniqueCompletedCount[entityRemoved!.DataType] == 0)
|
||||
_buildOrder.UniqueCompletedCount[entityRemoved!.DataType]--;
|
||||
if (_buildOrder.UniqueCompletedCount[entityRemoved!.DataType] == 0)
|
||||
UniqueCompletedTimes.Remove(entityRemoved.DataType);
|
||||
|
||||
if (entityRemoved.Info().Descriptive == DescriptiveType.Worker)
|
||||
@@ -251,14 +259,14 @@ public class BuildOrderService : IBuildOrderService
|
||||
WriteIndented = true
|
||||
};
|
||||
options.Converters.Add(new JsonStringEnumConverter());
|
||||
return JsonSerializer.Serialize(buildOrder, options);
|
||||
return JsonSerializer.Serialize(_buildOrder, options);
|
||||
}
|
||||
|
||||
public string BuildOrderAsYaml()
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
var serializer = new Serializer();
|
||||
stringBuilder.AppendLine(serializer.Serialize(buildOrder));
|
||||
stringBuilder.AppendLine(serializer.Serialize(_buildOrder));
|
||||
var buildOrderText = stringBuilder.ToString();
|
||||
return buildOrderText;
|
||||
}
|
||||
@@ -266,7 +274,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
public List<EntityModel> GetCompletedBefore(int interval)
|
||||
{
|
||||
return (from ordersAtTime in buildOrder.StartedOrders
|
||||
return (from ordersAtTime in _buildOrder.StartedOrders
|
||||
from orders in ordersAtTime.Value
|
||||
where ordersAtTime.Key + (orders.Production() == null ? 0 : orders.Production().BuildTime) <= interval
|
||||
select orders).ToList();
|
||||
@@ -274,7 +282,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
public List<EntityModel> GetHarvestPointsCompletedBefore(int interval)
|
||||
{
|
||||
return (from ordersAtTime in buildOrder.StartedOrders
|
||||
return (from ordersAtTime in _buildOrder.StartedOrders
|
||||
from orders in ordersAtTime.Value
|
||||
where ordersAtTime.Key + (orders.Production() == null ? 0 : orders.Production().BuildTime) <= interval
|
||||
where orders.Harvest() != null
|
||||
@@ -284,24 +292,24 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
public void SetName(string name)
|
||||
{
|
||||
buildOrder.Name = name;
|
||||
_buildOrder.Name = name;
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return buildOrder.Name;
|
||||
return _buildOrder.Name;
|
||||
}
|
||||
|
||||
public void SetNotes(string notes)
|
||||
{
|
||||
buildOrder.Notes = notes;
|
||||
_buildOrder.Notes = notes;
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
public string GetNotes()
|
||||
{
|
||||
return buildOrder.Notes;
|
||||
return _buildOrder.Notes;
|
||||
}
|
||||
|
||||
public void DeprecatedSetColor(string color)
|
||||
@@ -315,37 +323,39 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
lastInterval = 0;
|
||||
buildOrder.Initialize(DataType.FACTION_Aru);
|
||||
_lastInterval = 0;
|
||||
_buildOrder.Initialize(DataType.FACTION_Aru);
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
public bool AddWaitTo(int interval, TimingService timingService)
|
||||
{
|
||||
if (lastInterval >= interval) return false;
|
||||
|
||||
if (interval > timingService.GetAttackTime()) return false;
|
||||
|
||||
|
||||
if (!buildOrder.StartedOrders.ContainsKey(lastInterval))
|
||||
buildOrder.StartedOrders.Add(lastInterval, new List<EntityModel>());
|
||||
|
||||
if (!buildOrder.CompletedOrders.ContainsKey(lastInterval))
|
||||
buildOrder.CompletedOrders.Add(lastInterval, new List<EntityModel>());
|
||||
|
||||
NotifyDataChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
public int? WillMeetTrainingQueue(EntityModel entity)
|
||||
{
|
||||
var supply = entity.Supply();
|
||||
var production = entity.Production();
|
||||
if (supply == null || production == null || supply.Takes.Equals(0)) return 1;
|
||||
|
||||
if (supply == null || supply.Takes.Equals(0)) return 0;
|
||||
var producedBy = production.ProducedBy;
|
||||
if (producedBy == null)
|
||||
return 1;
|
||||
|
||||
var uniqueCompleted = _buildOrder.UniqueCompleted[producedBy];
|
||||
|
||||
|
||||
foreach (var supplyAtTime in buildOrder.SupplyCountTimes)
|
||||
if (supply.Takes + buildOrder.CurrentSupplyUsed < supplyAtTime.Key)
|
||||
foreach (var used in _buildOrder.TrainingCapacityUsed)
|
||||
{
|
||||
//used.UsedBuilding
|
||||
}
|
||||
|
||||
foreach (var atTime in uniqueCompleted)
|
||||
{
|
||||
foreach (var productionEntity in uniqueCompleted[atTime.Key])
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var supplyAtTime in _buildOrder.SupplyCountTimes)
|
||||
if (supply.Takes + _buildOrder.CurrentSupplyUsed < supplyAtTime.Key)
|
||||
return supplyAtTime.Value;
|
||||
|
||||
return null;
|
||||
@@ -375,14 +385,14 @@ public class BuildOrderService : IBuildOrderService
|
||||
}
|
||||
|
||||
if (withEconomy.GetOverTime().Last().Ether < production.Ether)
|
||||
toastService.AddToast(new ToastModel
|
||||
_toastService.AddToast(new ToastModel
|
||||
{
|
||||
Title = "Not Enough Ether", Message = "Build more ether extractors!",
|
||||
SeverityType = SeverityType.Error
|
||||
});
|
||||
|
||||
if (withEconomy.GetOverTime().Last().Alloy < production.Alloy)
|
||||
toastService.AddToast(new ToastModel
|
||||
_toastService.AddToast(new ToastModel
|
||||
{
|
||||
Title = "Not Enough Alloy", Message = "Build more bases!",
|
||||
SeverityType = SeverityType.Error
|
||||
@@ -396,7 +406,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
var minSupplyInterval = WillMeetSupply(entity);
|
||||
if (minSupplyInterval == null)
|
||||
{
|
||||
toastService.AddToast(new ToastModel
|
||||
_toastService.AddToast(new ToastModel
|
||||
{
|
||||
Title = "Supply Cap Reached", Message = "Build more supply!",
|
||||
SeverityType = SeverityType.Error
|
||||
@@ -415,7 +425,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
var minSupplyInterval = WillMeetSupply(entity);
|
||||
if (minSupplyInterval == null)
|
||||
{
|
||||
toastService.AddToast(new ToastModel
|
||||
_toastService.AddToast(new ToastModel
|
||||
{
|
||||
Title = "Supply Cap Reached", Message = "Build more supply!",
|
||||
SeverityType = SeverityType.Error
|
||||
@@ -435,7 +445,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
var minRequirementInterval = WillMeetRequirements(entity);
|
||||
if (minRequirementInterval == null)
|
||||
{
|
||||
toastService.AddToast(new ToastModel
|
||||
_toastService.AddToast(new ToastModel
|
||||
{
|
||||
Title = "Missing Requirements", Message = "You don't have what's needed for this unit.",
|
||||
SeverityType = SeverityType.Error
|
||||
|
||||
Reference in New Issue
Block a user