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
@@ -42,27 +42,6 @@
}
}
</div>
<div>
<div>Depleted</div>
//TODO WIP
@foreach (var ordersAtTime in buildOrderService.CompletedOrders.Reverse())
{
foreach (var order in ordersAtTime.Value)
{
<div>
@ordersAtTime.Key | T @Interval.ToTime(ordersAtTime.Key)
</div>
<div>
@order.Info().Name
</div>
<br/>
}
}
</div>
</div>
<style>
+5 -5
View File
@@ -3863,16 +3863,16 @@ public abstract class DATA
Description = "Gain 100 Ether over 50 seconds"
})
.AddPart(new EntityHotkeyModel { Hotkey = "W", HotkeyGroup = "CONTROL" })
.AddPart(new EntityFactionModel { Faction = DataType.FACTION_QRath })
.AddPart(new EntityFactionModel { Faction = DataType.FACTION_Aru })
.AddPart(new EntityRequirementModel
{
Id = DataType.BUILDING_Acropolis,
Id = DataType.STARTING_TownHall_Aru,
Requirement = RequirementType.Morph
})
.AddPart(new EntityProductionModel { Alloy = 50, Cooldown = 50, RequiresWorker = false })
.AddPart(new EntityHarvestModel
{
HarvestedPerInterval = 5, RequiresWorker = false, Resource = ResourceType.Ether, Slots = 1,
HarvestedPerInterval = 2, RequiresWorker = false, Resource = ResourceType.Ether, Slots = 1,
TotalAmount = 100
})
},
@@ -3888,13 +3888,13 @@ public abstract class DATA
.AddPart(new EntityFactionModel { Faction = DataType.FACTION_QRath })
.AddPart(new EntityRequirementModel
{
Id = DataType.BUILDING_Acropolis,
Id = DataType.STARTING_TownHall_QRath,
Requirement = RequirementType.Morph
})
.AddPart(new EntityProductionModel { Alloy = 50, Cooldown = 50, RequiresWorker = false })
.AddPart(new EntityHarvestModel
{
HarvestedPerInterval = 5, RequiresWorker = false, Resource = ResourceType.Ether, Slots = 1,
HarvestedPerInterval = 2, RequiresWorker = false, Resource = ResourceType.Ether, Slots = 1,
TotalAmount = 100
})
},
+3 -4
View File
@@ -12,13 +12,12 @@ public class EntityHarvestModel : IEntityPartInterface
public int TotalAmount { get; set; }
public bool RequiresWorker { get; set; }
public float StartedAt { get; set; }
public bool IsDepleted(float interval)
public bool IsDepleted(float interval, float startedAt)
{
var lifeTime = interval - StartedAt;
var lifeTime = interval - startedAt;
var totalHarvested = (lifeTime - 1) * HarvestedPerInterval;
var totalHarvested = lifeTime * HarvestedPerInterval;
return totalHarvested > TotalAmount;
}
+1 -1
View File
@@ -308,7 +308,7 @@ public interface IBuildOrderService
public int? WillMeetSupply(EntityModel entity);
public Dictionary<int, List<EntityModel>> GetOrders();
public List<EntityModel> GetCompletedBefore(int interval);
public List<EntityModel> GetHarvestPointsCompletedBefore(int interval);
public List<EntityModel> GetUndepletedHarvestPointsCompletedBefore(int interval);
public void RemoveLast();
public void Reset();
+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();
}