feat(BuildCalc) Waits now work
This commit is contained in:
@@ -9,17 +9,31 @@
|
|||||||
<FormDisplayComponent Label="Time">
|
<FormDisplayComponent Label="Time">
|
||||||
<Display>@BuildOrderService.GetLastRequestInterval() | T @Interval.ToTime(BuildOrderService.GetLastRequestInterval())</Display>
|
<Display>@BuildOrderService.GetLastRequestInterval() | T @Interval.ToTime(BuildOrderService.GetLastRequestInterval())</Display>
|
||||||
</FormDisplayComponent>
|
</FormDisplayComponent>
|
||||||
<FormDisplayComponent Label="Alloy">
|
<div class="bankRow">
|
||||||
<Display>@economy.Alloy</Display>
|
<FormDisplayComponent Label="Alloy">
|
||||||
</FormDisplayComponent>
|
<Display>@economy.Alloy</Display>
|
||||||
<FormDisplayComponent Label="Ether">
|
</FormDisplayComponent>
|
||||||
<Display>@economy.Ether</Display>
|
<FormDisplayComponent Label="Ether">
|
||||||
</FormDisplayComponent>
|
<Display>@economy.Ether</Display>
|
||||||
<FormDisplayComponent Label="Supply">
|
</FormDisplayComponent>
|
||||||
<Display>@supplyTaken / @supplyGranted (@(supplyGranted / 16)@(extraBuildings > 0 ? "+" + extraBuildings : ""))</Display>
|
</div>
|
||||||
</FormDisplayComponent>
|
<div class="bankRow">
|
||||||
|
<FormDisplayComponent Label="Pyre">
|
||||||
|
<Display>@economy.Pyre</Display>
|
||||||
|
</FormDisplayComponent>
|
||||||
|
<FormDisplayComponent Label="Supply">
|
||||||
|
<Display>@supplyTaken / @supplyGranted (@(supplyGranted / 16)@(extraBuildings > 0 ? "+" + extraBuildings : ""))</Display>
|
||||||
|
</FormDisplayComponent>
|
||||||
|
</div>
|
||||||
</FormLayoutComponent>
|
</FormLayoutComponent>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.bankRow {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
@@ -61,6 +75,8 @@
|
|||||||
|
|
||||||
void OnBuildOrderChanged()
|
void OnBuildOrderChanged()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("OnBuildOrderChanged()");
|
||||||
|
|
||||||
economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval());
|
economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval());
|
||||||
|
|
||||||
var ordersOverTime = BuildOrderService.GetOrders();
|
var ordersOverTime = BuildOrderService.GetOrders();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<FormNumberComponent Max="600"
|
<FormNumberComponent Max="600"
|
||||||
Min="0"
|
Min="0"
|
||||||
Value="30"
|
Value="@WaitTime"
|
||||||
OnChange="@OnWaitTimeChanged">
|
OnChange="@OnWaitTimeChanged">
|
||||||
<FormLabelComponent>Wait Time</FormLabelComponent>
|
<FormLabelComponent>Wait Time</FormLabelComponent>
|
||||||
<FormInfoComponent>Not implemented</FormInfoComponent>
|
<FormInfoComponent>Not implemented</FormInfoComponent>
|
||||||
@@ -36,12 +36,15 @@
|
|||||||
|
|
||||||
void OnWaitTimeChanged(ChangeEventArgs changeEventArgs)
|
void OnWaitTimeChanged(ChangeEventArgs changeEventArgs)
|
||||||
{
|
{
|
||||||
toastService.AddToast(new ToastModel { Title = "Not Implemented", SeverityType = SeverityType.Warning, Message = "The ability to wait for X seconds in a build order hasn't been implemented yet." });
|
WaitTime = (int)changeEventArgs.Value!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWaitClicked()
|
public void OnWaitClicked()
|
||||||
{
|
{
|
||||||
toastService.AddToast(new ToastModel { Title = "Not Implemented", SeverityType = SeverityType.Warning, Message = "The ability to wait for X seconds in a build order hasn't been implemented yet." });
|
if (buildOrderService.AddWait(WaitTime))
|
||||||
|
{
|
||||||
|
economyService.Calculate(buildOrderService, timingService, buildOrderService.GetLastRequestInterval());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ShouldRender()
|
protected override bool ShouldRender()
|
||||||
@@ -60,4 +63,6 @@
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int WaitTime { get; set; } = 30;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -307,14 +307,16 @@ public interface IBuildOrderService
|
|||||||
|
|
||||||
public bool Add(EntityModel entity, IEconomyService withEconomy, IToastService toastService);
|
public bool Add(EntityModel entity, IEconomyService withEconomy, IToastService toastService);
|
||||||
public void Add(EntityModel entity, int atInterval);
|
public void Add(EntityModel entity, int atInterval);
|
||||||
|
public bool AddWait(int forInterval);
|
||||||
|
|
||||||
public void SetName(string Name);
|
|
||||||
|
public void SetName(string name);
|
||||||
public string GetName();
|
public string GetName();
|
||||||
|
|
||||||
public void SetNotes(string Notes);
|
public void SetNotes(string notes);
|
||||||
public string GetNotes();
|
public string GetNotes();
|
||||||
|
|
||||||
public void DeprecatedSetColor(string Color);
|
public void DeprecatedSetColor(string color);
|
||||||
public string GetColor();
|
public string GetColor();
|
||||||
|
|
||||||
public int? WillMeetRequirements(EntityModel entity);
|
public int? WillMeetRequirements(EntityModel entity);
|
||||||
|
|||||||
@@ -87,6 +87,28 @@ public class BuildOrderService : IBuildOrderService
|
|||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AddWait(int forInterval)
|
||||||
|
{
|
||||||
|
if (forInterval == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastInterval += forInterval;
|
||||||
|
|
||||||
|
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? WillMeetRequirements(EntityModel entity)
|
public int? WillMeetRequirements(EntityModel entity)
|
||||||
{
|
{
|
||||||
@@ -139,6 +161,15 @@ public class BuildOrderService : IBuildOrderService
|
|||||||
{
|
{
|
||||||
if (buildOrder.StartedOrders.Keys.Count > 1)
|
if (buildOrder.StartedOrders.Keys.Count > 1)
|
||||||
{
|
{
|
||||||
|
if (buildOrder.StartedOrders.Count == 0)
|
||||||
|
{
|
||||||
|
buildOrder.StartedOrders.Remove(buildOrder.StartedOrders.Last().Key);
|
||||||
|
buildOrder.CompletedOrders.Remove(buildOrder.CompletedOrders.Last().Key);
|
||||||
|
|
||||||
|
lastInterval = buildOrder.StartedOrders.Last().Key;
|
||||||
|
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();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user