From fe1a583da966a5c6812f5e0ecde52a86bb2fa475 Mon Sep 17 00:00:00 2001 From: 6d486f49 <76097bcc@gmail.com> Date: Fri, 7 Nov 2025 18:22:21 -0500 Subject: [PATCH] Fixed bugs --- .../Parts/BuildChartComponent.razor | 24 +++++++++---------- .../Parts/ChartComponent.razor | 16 ++++++------- Model/BuildOrders/BuildOrderModel.cs | 2 +- Model/Entity/EntityModel.cs | 2 +- Model/Entity/Parts/IEntityPartInterface.cs | 5 +++- Services/Immortal/BuildOrderService.cs | 12 +++------- Services/Immortal/EconomyComparisonService.cs | 2 +- Services/Immortal/EconomyService.cs | 2 +- 8 files changed, 31 insertions(+), 34 deletions(-) diff --git a/IGP/Pages/BuildCalculator/Parts/BuildChartComponent.razor b/IGP/Pages/BuildCalculator/Parts/BuildChartComponent.razor index 9377355..56c677e 100644 --- a/IGP/Pages/BuildCalculator/Parts/BuildChartComponent.razor +++ b/IGP/Pages/BuildCalculator/Parts/BuildChartComponent.razor @@ -224,21 +224,21 @@ else var economyAtSecond = economyOverTime[interval]; var alloyWorkerHarvesters = from harvester in economyAtSecond.HarvestPoints - where harvester.Harvest() != null - where harvester.Harvest().RequiresWorker - where harvester.Harvest().Resource == ResourceType.Alloy + where harvester.Harvester() != null + where harvester.Harvester().RequiresWorker + where harvester.Harvester().Resource == ResourceType.Alloy select harvester; var alloyAutomaticHarvesters = from harvester in economyAtSecond.HarvestPoints - where harvester.Harvest() != null - where harvester.Harvest().RequiresWorker == false - where harvester.Harvest().Resource == ResourceType.Alloy + where harvester.Harvester() != null + where harvester.Harvester().RequiresWorker == false + where harvester.Harvester().Resource == ResourceType.Alloy select harvester; var etherAutomaticHarvesters = from harvester in economyAtSecond.HarvestPoints - where harvester.Harvest() != null - where harvester.Harvest().RequiresWorker == false - where harvester.Harvest().Resource == ResourceType.Ether + where harvester.Harvester() != null + where harvester.Harvester().RequiresWorker == false + where harvester.Harvester().Resource == ResourceType.Ether select harvester; float autoAlloy = 0; @@ -250,7 +250,7 @@ else foreach (var alloyAutoHarvester in alloyAutomaticHarvesters) { - autoAlloy += alloyAutoHarvester.Harvest().Slots * alloyAutoHarvester.Harvest().HarvestedPerInterval; + autoAlloy += alloyAutoHarvester.Harvester().Slots * alloyAutoHarvester.Harvester().HarvestedPerInterval; var production = alloyAutoHarvester.Production(); if (production != null) { @@ -260,7 +260,7 @@ else foreach (var alloyWorkerHarvester in alloyWorkerHarvesters) { - workerSlots += alloyWorkerHarvester.Harvest().Slots; + workerSlots += alloyWorkerHarvester.Harvester().Slots; var production = alloyWorkerHarvester.Production(); if (production != null) { @@ -270,7 +270,7 @@ else foreach (var etherWorkerHarvester in etherAutomaticHarvesters) { - autoEther += etherWorkerHarvester.Harvest().Slots * etherWorkerHarvester.Harvest().HarvestedPerInterval; + autoEther += etherWorkerHarvester.Harvester().Slots * etherWorkerHarvester.Harvester().HarvestedPerInterval; var production = etherWorkerHarvester.Production(); if (production != null) { diff --git a/IGP/Pages/EconomyComparison/Parts/ChartComponent.razor b/IGP/Pages/EconomyComparison/Parts/ChartComponent.razor index 0f0b397..2b63629 100644 --- a/IGP/Pages/EconomyComparison/Parts/ChartComponent.razor +++ b/IGP/Pages/EconomyComparison/Parts/ChartComponent.razor @@ -132,15 +132,15 @@ var economyAtSecond = economyOverTime[interval]; var alloyWorkerHarvesters = from harvester in economyAtSecond.HarvestPoints - where harvester.Harvest() != null - where harvester.Harvest().RequiresWorker - where harvester.Harvest().Resource == ResourceType.Alloy + where harvester.Harvester() != null + where harvester.Harvester().RequiresWorker + where harvester.Harvester().Resource == ResourceType.Alloy select harvester; var alloyAutomaticHarvesters = from harvester in economyAtSecond.HarvestPoints - where harvester.Harvest() != null - where harvester.Harvest().RequiresWorker == false - where harvester.Harvest().Resource == ResourceType.Alloy + where harvester.Harvester() != null + where harvester.Harvester().RequiresWorker == false + where harvester.Harvester().Resource == ResourceType.Alloy select harvester; @@ -152,7 +152,7 @@ foreach (var alloyAutoHarvester in alloyAutomaticHarvesters) { - autoAlloy += alloyAutoHarvester.Harvest().Slots * alloyAutoHarvester.Harvest().HarvestedPerInterval; + autoAlloy += alloyAutoHarvester.Harvester().Slots * alloyAutoHarvester.Harvester().HarvestedPerInterval; var production = alloyAutoHarvester.Production(); if (production != null) { @@ -162,7 +162,7 @@ foreach (var alloyWorkerHarvester in alloyWorkerHarvesters) { - workerSlots += alloyWorkerHarvester.Harvest().Slots; + workerSlots += alloyWorkerHarvester.Harvester().Slots; var production = alloyWorkerHarvester.Production(); if (production != null) { diff --git a/Model/BuildOrders/BuildOrderModel.cs b/Model/BuildOrders/BuildOrderModel.cs index f147f15..5550203 100644 --- a/Model/BuildOrders/BuildOrderModel.cs +++ b/Model/BuildOrders/BuildOrderModel.cs @@ -94,7 +94,7 @@ public class BuildOrderModel return (from ordersAtTime in StartedOrders from orders in ordersAtTime.Value where ordersAtTime.Key + (orders.Production() == null ? 0 : orders.Production().BuildTime) <= interval - where orders.Harvest() != null + where orders.Harvester() != null select orders).ToList(); } } \ No newline at end of file diff --git a/Model/Entity/EntityModel.cs b/Model/Entity/EntityModel.cs index 9559275..1c23a92 100644 --- a/Model/Entity/EntityModel.cs +++ b/Model/Entity/EntityModel.cs @@ -255,7 +255,7 @@ public class EntityModel } - public EntityHarvesterModel Harvest() + public EntityHarvesterModel? Harvester() { return (EntityHarvesterModel)EntityParts.Find(x => x.GetType() == typeof(EntityHarvesterModel))!; } diff --git a/Model/Entity/Parts/IEntityPartInterface.cs b/Model/Entity/Parts/IEntityPartInterface.cs index 43738b9..0e88602 100644 --- a/Model/Entity/Parts/IEntityPartInterface.cs +++ b/Model/Entity/Parts/IEntityPartInterface.cs @@ -1,6 +1,9 @@ -namespace Model.Entity.Parts; +using System.Text.Json.Serialization; + +namespace Model.Entity.Parts; public class IEntityPartInterface { + [JsonIgnore] public EntityModel Parent { get; set; } } \ No newline at end of file diff --git a/Services/Immortal/BuildOrderService.cs b/Services/Immortal/BuildOrderService.cs index 6452ab3..728a0de 100644 --- a/Services/Immortal/BuildOrderService.cs +++ b/Services/Immortal/BuildOrderService.cs @@ -290,15 +290,9 @@ public class BuildOrderService : IBuildOrderService { return (from ordersAtTime in _buildOrder.StartedOrders from orders in ordersAtTime.Value - where ordersAtTime.Key + (orders.Production() == null - ? 0 - : orders.Production().BuildTime) <= interval - && !orders.Harvest().IsDepleted( - interval, - ordersAtTime.Key + (orders.Production() == null - ? 0 - : orders.Production().BuildTime)) - where orders.Harvest() != null + where orders.Harvester() != null + && ordersAtTime.Key + (orders.Production()?.BuildTime ?? 0) <= interval + && !orders.Harvester()!.IsDepleted(interval,ordersAtTime.Key + (orders.Production()?.BuildTime ?? 0)) select orders).ToList(); } diff --git a/Services/Immortal/EconomyComparisonService.cs b/Services/Immortal/EconomyComparisonService.cs index 0d5e477..ceafd42 100644 --- a/Services/Immortal/EconomyComparisonService.cs +++ b/Services/Immortal/EconomyComparisonService.cs @@ -181,7 +181,7 @@ public class EconomyComparisionService : IEconomyComparisonService // Add funds foreach (var entity in economyAtSecond.HarvestPoints) { - var harvester = entity.Harvest(); + var harvester = entity.Harvester(); if (harvester.RequiresWorker) if (harvester.Resource == ResourceType.Alloy) { diff --git a/Services/Immortal/EconomyService.cs b/Services/Immortal/EconomyService.cs index 0e69eac..5fb86d7 100644 --- a/Services/Immortal/EconomyService.cs +++ b/Services/Immortal/EconomyService.cs @@ -167,7 +167,7 @@ public class EconomyService : IEconomyService foreach (var harvesterPoint in - economyAtSecond.HarvestPoints.Select(entity => entity.Harvest())) + economyAtSecond.HarvestPoints.Select(entity => entity.Harvester())) //if (harvesterPoint.IsDepleted(economyAtSecond.Interval)) // continue; switch (harvesterPoint.RequiresWorker)