diff --git a/IGP/Pages/BuildCalculator/Parts/BankComponent.razor b/IGP/Pages/BuildCalculator/Parts/BankComponent.razor index 0f7f091..ec3fc18 100644 --- a/IGP/Pages/BuildCalculator/Parts/BankComponent.razor +++ b/IGP/Pages/BuildCalculator/Parts/BankComponent.razor @@ -9,17 +9,31 @@ @BuildOrderService.GetLastRequestInterval() | T @Interval.ToTime(BuildOrderService.GetLastRequestInterval()) - - @economy.Alloy - - - @economy.Ether - - - @supplyTaken / @supplyGranted (@(supplyGranted / 16)@(extraBuildings > 0 ? "+" + extraBuildings : "")) - +
+ + @economy.Alloy + + + @economy.Ether + +
+
+ + @economy.Pyre + + + @supplyTaken / @supplyGranted (@(supplyGranted / 16)@(extraBuildings > 0 ? "+" + extraBuildings : "")) + +
+ + @code { [Inject] @@ -61,6 +75,8 @@ void OnBuildOrderChanged() { + Console.WriteLine("OnBuildOrderChanged()"); + economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval()); var ordersOverTime = BuildOrderService.GetOrders(); diff --git a/IGP/Pages/BuildCalculator/Parts/OptionsComponent.razor b/IGP/Pages/BuildCalculator/Parts/OptionsComponent.razor index cd9a2d6..4a12249 100644 --- a/IGP/Pages/BuildCalculator/Parts/OptionsComponent.razor +++ b/IGP/Pages/BuildCalculator/Parts/OptionsComponent.razor @@ -16,7 +16,7 @@ Wait Time Not implemented @@ -36,12 +36,15 @@ 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() { - 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() @@ -60,4 +63,6 @@ #endif } + public int WaitTime { get; set; } = 30; + } \ No newline at end of file diff --git a/Services/IServices.cs b/Services/IServices.cs index d48346a..5684b32 100644 --- a/Services/IServices.cs +++ b/Services/IServices.cs @@ -307,14 +307,16 @@ public interface IBuildOrderService public bool Add(EntityModel entity, IEconomyService withEconomy, IToastService toastService); 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 void SetNotes(string Notes); + public void SetNotes(string notes); public string GetNotes(); - public void DeprecatedSetColor(string Color); + public void DeprecatedSetColor(string color); public string GetColor(); public int? WillMeetRequirements(EntityModel entity); diff --git a/Services/Immortal/BuildOrderService.cs b/Services/Immortal/BuildOrderService.cs index 690699d..0e1fb6e 100644 --- a/Services/Immortal/BuildOrderService.cs +++ b/Services/Immortal/BuildOrderService.cs @@ -87,6 +87,28 @@ public class BuildOrderService : IBuildOrderService NotifyDataChanged(); } + public bool AddWait(int forInterval) + { + if (forInterval == 0) + { + return false; + } + + lastInterval += forInterval; + + if (!buildOrder.StartedOrders.ContainsKey(lastInterval)) + buildOrder.StartedOrders.Add(lastInterval, new List()); + + if (!buildOrder.CompletedOrders.ContainsKey(lastInterval)) + buildOrder.CompletedOrders.Add(lastInterval, new List()); + + + NotifyDataChanged(); + + return true; + + } + public int? WillMeetRequirements(EntityModel entity) { @@ -139,6 +161,15 @@ public class BuildOrderService : IBuildOrderService { 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 lastCompleted = buildOrder.CompletedOrders.Keys.Last();