Temp is depleted logic

This commit is contained in:
Jonathan
2025-06-22 18:46:51 -04:00
parent 826717c47f
commit 1bc78306b8
6 changed files with 37 additions and 49 deletions
+9 -2
View File
@@ -286,11 +286,18 @@ public class BuildOrderService : IBuildOrderService
select orders).ToList();
}
public List<EntityModel> GetHarvestPointsCompletedBefore(int interval)
public List<EntityModel> GetUndepletedHarvestPointsCompletedBefore(int interval)
{
return (from ordersAtTime in _buildOrder.StartedOrders
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
&& !orders.Harvest().IsDepleted(
interval,
ordersAtTime.Key + (orders.Production() == null
? 0
: orders.Production().BuildTime))
where orders.Harvest() != null
select orders).ToList();
}
+19 -16
View File
@@ -72,11 +72,15 @@ public class EconomyService : IEconomyService
: buildEconomyOverTime[atInterval];
}
private static void SetupCurrentInterval(IBuildOrderService buildOrder, EconomyModel economyAtSecond, int interval)
private static void SetupCurrentInterval(
IBuildOrderService buildOrder,
EconomyModel economyAtSecond,
int interval)
{
economyAtSecond.Interval = interval;
economyAtSecond.HarvestPoints =
(from harvester in buildOrder.GetHarvestPointsCompletedBefore(interval)
(from harvester
in buildOrder.GetUndepletedHarvestPointsCompletedBefore(interval + 1) // One second into the future for completed harvest points
select harvester).ToList();
}
@@ -88,7 +92,7 @@ public class EconomyService : IEconomyService
foreach (var newEntity in completedAtInterval)
{
var entity = newEntity.Clone();
entity.Harvest().StartedAt = interval;
//entity.Harvest().StartedAt = interval;
economyAtSecond.HarvestPoints.Add(entity);
var production = newEntity.Production();
@@ -163,8 +167,8 @@ public class EconomyService : IEconomyService
foreach (var harvesterPoint in
economyAtSecond.HarvestPoints.Select(entity => entity.Harvest()))
{
if (harvesterPoint.IsDepleted(economyAtSecond.Interval))
continue;
//if (harvesterPoint.IsDepleted(economyAtSecond.Interval))
// continue;
switch (harvesterPoint.RequiresWorker)
{
@@ -215,17 +219,16 @@ public class EconomyService : IEconomyService
private void CarryOverEconomyFromPreviousInterval(int interval, EconomyModel economyAtSecond)
{
if (interval > 0)
{
economyAtSecond.Alloy = buildEconomyOverTime[interval - 1].Alloy;
economyAtSecond.Ether = buildEconomyOverTime[interval - 1].Ether;
economyAtSecond.Pyre = buildEconomyOverTime[interval - 1].Pyre;
economyAtSecond.WorkerCount = buildEconomyOverTime[interval - 1].WorkerCount;
economyAtSecond.BusyWorkerCount = buildEconomyOverTime[interval - 1].BusyWorkerCount;
economyAtSecond.CreatingWorkerCount = buildEconomyOverTime[interval - 1].CreatingWorkerCount;
economyAtSecond.HarvestPoints = buildEconomyOverTime[interval - 1].HarvestPoints.ToList();
economyAtSecond.CreatingWorkerDelays = buildEconomyOverTime[interval - 1].CreatingWorkerDelays.ToList();
}
if (interval <= 0) return;
economyAtSecond.Alloy = buildEconomyOverTime[interval - 1].Alloy;
economyAtSecond.Ether = buildEconomyOverTime[interval - 1].Ether;
economyAtSecond.Pyre = buildEconomyOverTime[interval - 1].Pyre;
economyAtSecond.WorkerCount = buildEconomyOverTime[interval - 1].WorkerCount;
economyAtSecond.BusyWorkerCount = buildEconomyOverTime[interval - 1].BusyWorkerCount;
economyAtSecond.CreatingWorkerCount = buildEconomyOverTime[interval - 1].CreatingWorkerCount;
economyAtSecond.HarvestPoints = buildEconomyOverTime[interval - 1].HarvestPoints.ToList();
economyAtSecond.CreatingWorkerDelays = buildEconomyOverTime[interval - 1].CreatingWorkerDelays.ToList();
}