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