Unfinished training queue code

This commit is contained in:
2022-04-21 15:17:00 -04:00
parent 89e12a8de0
commit 015262de9a
11 changed files with 171 additions and 206 deletions
@@ -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);
}
}