Browse Source

Temp is depleted logic

main
Jonathan 11 months ago
parent
commit
1bc78306b8
  1. 21
      IGP/Pages/BuildCalculator/Parts/HighlightsComponent.razor
  2. 10
      Model/Entity/Data/DATA.cs
  3. 7
      Model/Entity/Parts/EntityHarvestModel.cs
  4. 2
      Services/IServices.cs
  5. 11
      Services/Immortal/BuildOrderService.cs
  6. 19
      Services/Immortal/EconomyService.cs

21
IGP/Pages/BuildCalculator/Parts/HighlightsComponent.razor

@ -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>

10
Model/Entity/Data/DATA.cs

@ -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
})
},

7
Model/Entity/Parts/EntityHarvestModel.cs

@ -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;
}

2
Services/IServices.cs

@ -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();

11
Services/Immortal/BuildOrderService.cs

@ -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
Services/Immortal/EconomyService.cs

@ -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,8 +219,8 @@ public class EconomyService : IEconomyService
private void CarryOverEconomyFromPreviousInterval(int interval, EconomyModel economyAtSecond)
{
if (interval > 0)
{
if (interval <= 0) return;
economyAtSecond.Alloy = buildEconomyOverTime[interval - 1].Alloy;
economyAtSecond.Ether = buildEconomyOverTime[interval - 1].Ether;
economyAtSecond.Pyre = buildEconomyOverTime[interval - 1].Pyre;
@ -226,7 +230,6 @@ public class EconomyService : IEconomyService
economyAtSecond.HarvestPoints = buildEconomyOverTime[interval - 1].HarvestPoints.ToList();
economyAtSecond.CreatingWorkerDelays = buildEconomyOverTime[interval - 1].CreatingWorkerDelays.ToList();
}
}
private event Action OnChange = null!;

Loading…
Cancel
Save