Harvest points can now be depleted
This commit is contained in:
@@ -136,7 +136,6 @@ public interface IWebsiteService
|
||||
public bool IsLoaded();
|
||||
}
|
||||
|
||||
|
||||
public interface INoteService
|
||||
{
|
||||
public List<NoteContentModel> NoteContentModels { get; set; }
|
||||
|
||||
@@ -172,7 +172,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
|
||||
if (supply == null || supply.Takes.Equals(0)) return 0;
|
||||
|
||||
foreach (var supplyAtTime in
|
||||
foreach (var supplyAtTime in
|
||||
_buildOrder.SupplyCountTimes
|
||||
.Where(supplyAtTime => supply.Takes + _buildOrder.CurrentSupplyUsed <= supplyAtTime.Key))
|
||||
return supplyAtTime.Value;
|
||||
@@ -198,7 +198,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
public void RemoveLast()
|
||||
{
|
||||
if (_buildOrder.StartedOrders.Keys.Count <= 1) return;
|
||||
|
||||
|
||||
if (_buildOrder.StartedOrders.Count == 0)
|
||||
{
|
||||
_buildOrder.StartedOrders.Remove(_buildOrder.StartedOrders.Last().Key);
|
||||
@@ -357,9 +357,10 @@ public class BuildOrderService : IBuildOrderService
|
||||
while (true)
|
||||
{
|
||||
var usedSlots = 0;
|
||||
foreach (var used in
|
||||
foreach (var used in
|
||||
_buildOrder.TrainingCapacityUsed
|
||||
.Where(used => checkedInterval >= used.StartingUsageTime && checkedInterval < used.StopUsageTime))
|
||||
.Where(used =>
|
||||
checkedInterval >= used.StartingUsageTime && checkedInterval < used.StopUsageTime))
|
||||
{
|
||||
usedSlots += used.UsedSlots;
|
||||
var duration = used.StopUsageTime - used.StartingUsageTime;
|
||||
@@ -399,7 +400,7 @@ public class BuildOrderService : IBuildOrderService
|
||||
if (!(economyAtSecond.Alloy >= production.Alloy)
|
||||
|| !(economyAtSecond.Ether >= production.Ether)
|
||||
|| !(economyAtSecond.Pyre >= production.Pyre)) continue;
|
||||
|
||||
|
||||
atInterval = interval;
|
||||
|
||||
if (entity.EntityType != EntityType.Army) atInterval += _timingService.BuildingInputDelay;
|
||||
|
||||
@@ -67,8 +67,8 @@ public class EconomyService : IEconomyService
|
||||
|
||||
public EconomyModel GetEconomy(int atInterval)
|
||||
{
|
||||
return atInterval >= buildEconomyOverTime.Count
|
||||
? buildEconomyOverTime.Last()
|
||||
return atInterval >= buildEconomyOverTime.Count
|
||||
? buildEconomyOverTime.Last()
|
||||
: buildEconomyOverTime[atInterval];
|
||||
}
|
||||
|
||||
@@ -84,10 +84,12 @@ public class EconomyService : IEconomyService
|
||||
EconomyModel economyAtSecond)
|
||||
{
|
||||
if (!buildOrder.CompletedOrders.TryGetValue(interval, out var completedAtInterval)) return;
|
||||
|
||||
|
||||
foreach (var newEntity in completedAtInterval)
|
||||
{
|
||||
economyAtSecond.HarvestPoints.Add(newEntity);
|
||||
var entity = newEntity.Clone();
|
||||
entity.Harvest().StartedAt = interval;
|
||||
economyAtSecond.HarvestPoints.Add(entity);
|
||||
|
||||
var production = newEntity.Production();
|
||||
if (production is { RequiresWorker: true }) economyAtSecond.BusyWorkerCount -= 1;
|
||||
@@ -99,7 +101,7 @@ public class EconomyService : IEconomyService
|
||||
{
|
||||
if (!buildOrder.StartedOrders.TryGetValue(interval, out var ordersAtTime)) return;
|
||||
|
||||
foreach (var production in
|
||||
foreach (var production in
|
||||
ordersAtTime.Select(order => EntityModel.GetDictionary()[order.DataType])
|
||||
.Select(foundEntity => foundEntity.Production())
|
||||
.OfType<EntityProductionModel>())
|
||||
@@ -107,7 +109,7 @@ public class EconomyService : IEconomyService
|
||||
economyAtSecond.Alloy -= production.Alloy;
|
||||
economyAtSecond.Ether -= production.Ether;
|
||||
economyAtSecond.Pyre -= production.Pyre;
|
||||
|
||||
|
||||
if (production.RequiresWorker) economyAtSecond.BusyWorkerCount += 1;
|
||||
if (production.ConsumesWorker) economyAtSecond.WorkerCount -= 1;
|
||||
}
|
||||
@@ -116,7 +118,7 @@ public class EconomyService : IEconomyService
|
||||
private static void MakeNeededNewWorkersRequests(int workersNeeded, EconomyModel economyAtSecond)
|
||||
{
|
||||
if (workersNeeded <= economyAtSecond.CreatingWorkerCount) return;
|
||||
|
||||
|
||||
economyAtSecond.CreatingWorkerCount += 1;
|
||||
economyAtSecond.CreatingWorkerDelays.Add(20);
|
||||
}
|
||||
@@ -129,12 +131,12 @@ public class EconomyService : IEconomyService
|
||||
var createdWorkers = 0;
|
||||
|
||||
if (economyAtSecond.CreatingWorkerCount <= 0) return createdWorkers;
|
||||
|
||||
|
||||
for (var i = 0; i < economyAtSecond.CreatingWorkerDelays.Count; i++)
|
||||
if (economyAtSecond.CreatingWorkerDelays[i] > 0)
|
||||
{
|
||||
if (!(economyAtSecond.Alloy > 2.5f)) continue;
|
||||
|
||||
|
||||
economyAtSecond.Alloy -= 2.5f;
|
||||
economyAtSecond.CreatingWorkerDelays[i]--;
|
||||
}
|
||||
@@ -157,9 +159,13 @@ public class EconomyService : IEconomyService
|
||||
{
|
||||
var workersNeeded = 0;
|
||||
|
||||
foreach (var harvesterPoint in
|
||||
|
||||
foreach (var harvesterPoint in
|
||||
economyAtSecond.HarvestPoints.Select(entity => entity.Harvest()))
|
||||
{
|
||||
if (harvesterPoint.IsDepleted(economyAtSecond.Interval))
|
||||
continue;
|
||||
|
||||
switch (harvesterPoint.RequiresWorker)
|
||||
{
|
||||
case true:
|
||||
@@ -167,9 +173,10 @@ public class EconomyService : IEconomyService
|
||||
if (harvesterPoint.Resource == ResourceType.Alloy)
|
||||
{
|
||||
var usedWorkers = Math.Min(harvesterPoint.Slots, freeWorkers);
|
||||
|
||||
economyAtSecond.Alloy += harvesterPoint.HarvestedPerInterval * usedWorkers;
|
||||
economyAtSecond.AlloyIncome += harvesterPoint.HarvestedPerInterval * usedWorkers;
|
||||
|
||||
|
||||
freeWorkers -= usedWorkers;
|
||||
|
||||
if (usedWorkers < harvesterPoint.Slots) workersNeeded += 1;
|
||||
|
||||
Reference in New Issue
Block a user