feat(BuildCalc) Optimized the build calculator

This commit is contained in:
2022-04-13 15:13:06 -04:00
parent 656b914c6e
commit 39db0afbe5
22 changed files with 803 additions and 561 deletions
+18 -16
View File
@@ -9,6 +9,8 @@ public class BuildOrderModel
{
public string Name { get; set; } = "";
public string Color { get; set; } = "red";
public int CurrentSupplyUsed { get; set; } = 0;
public Dictionary<int, List<EntityModel>> StartedOrders { get; set; } = new()
{
@@ -33,28 +35,28 @@ public class BuildOrderModel
}
}
};
public Dictionary<string, int> UniqueCompletedTimes { get; set; } = new()
{
{
DataType.STARTING_Bastion, 0
}
};
public Dictionary<int, int> SupplyCountTimes { get; set; } = new()
{
{
0, 0
}
};
public string Notes { get; set; } = @"";
public List<string> BuildTypes { get; set; } = new();
public List<EntityModel> GetOrdersAt(int interval)
{
return (from ordersAtTime in StartedOrders
from orders in ordersAtTime.Value
where ordersAtTime.Key == interval
select orders).ToList();
}
public List<EntityModel> GetCompletedAt(int interval)
{
return (from ordersAtTime in StartedOrders
from orders in ordersAtTime.Value
where ordersAtTime.Key + (orders.Production() == null ? 0 : orders.Production().BuildTime) == interval
select orders).ToList();
}
public List<EntityModel> GetCompletedBefore(int interval)
{
return (from ordersAtTime in StartedOrders
+12 -8
View File
@@ -99,8 +99,8 @@ public class EconomyOverTimeModel
}
// Remove Funds from Build Order
var ordersAtTime = buildOrder.GetOrdersAt(interval);
if (buildOrder.StartedOrders.TryGetValue(interval, out var ordersAtTime))
{
foreach (var order in ordersAtTime)
{
var foundEntity = EntityModel.GetDictionary()[order.DataType];
@@ -115,16 +115,20 @@ public class EconomyOverTimeModel
if (production.RequiresWorker) economyAtSecond.BusyWorkerCount += 1;
}
}
}
// Handle new entities
var completedAtInterval = buildOrder.GetCompletedAt(interval);
foreach (var newEntity in completedAtInterval)
if (buildOrder.StartedOrders.TryGetValue(interval, out var ordersCompletedAtTime))
{
var harvest = newEntity;
if (harvest != null) economyAtSecond.Harvesters.Add(harvest);
foreach (var newEntity in ordersCompletedAtTime)
{
var harvest = newEntity;
if (harvest != null) economyAtSecond.Harvesters.Add(harvest);
var production = newEntity.Production();
if (production != null && production.RequiresWorker) economyAtSecond.BusyWorkerCount -= 1;
var production = newEntity.Production();
if (production != null && production.RequiresWorker) economyAtSecond.BusyWorkerCount -= 1;
}
}
}
}
+11 -16
View File
@@ -1435,10 +1435,7 @@ public class DATA
.AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB" })
.AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 100, Ether = 100, BuildTime = 100 })
.AddPart(new EntityRequirementModel
{
Requirement = RequirementType.Production_Building
})
},
{
@@ -1465,10 +1462,7 @@ public class DATA
.AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB", HoldSpace = true})
.AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 100, Ether = 100, BuildTime = 43 })
.AddPart(new EntityRequirementModel
{
Requirement = RequirementType.Production_Building
})
},
{
@@ -1482,10 +1476,7 @@ public class DATA
.AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "TAB" })
.AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 50, Ether = 100, BuildTime = 60 })
.AddPart(new EntityRequirementModel
{
Requirement = RequirementType.Production_Building
})
},
{
DataType.UPGRADE_RelicOfTheWrathfulGaze,
@@ -1512,7 +1503,7 @@ public class DATA
.AddPart(new EntityHotkeyModel { Hotkey = "W", HotkeyGroup = "TAB" })
.AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 50, Ether = 75, BuildTime = 55 })
.AddPart(new EntityRequirementModel { Requirement = RequirementType.Production_Building })
.AddPart(new EntityRequirementModel { Id = DataType.BUILDING_Reliquary, Requirement = RequirementType.Production_Building })
},
{
DataType.UPGRADE_ZephyrRange,
@@ -1525,7 +1516,7 @@ public class DATA
.AddPart(new EntityHotkeyModel { Hotkey = "E", HotkeyGroup = "TAB" })
.AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityProductionModel { Alloy = 150, Ether = 100, BuildTime = 43 })
.AddPart(new EntityRequirementModel { Requirement = RequirementType.Production_Building })
.AddPart(new EntityRequirementModel { Id = DataType.UPGRADE_ZephyrRange, Requirement = RequirementType.Production_Building })
.AddPart(new EntityIdUpgradeModel { Id = DataType.UPGRADE_WindStep })
.AddPart(new EntityIdUpgradeModel { Id = DataType.UPGRADE_ZephyrRange })
},
@@ -1559,6 +1550,7 @@ public class DATA
.AddPart(new EntityProductionModel { Alloy = 100, Ether = 100, BuildTime = 43 })
.AddPart(new EntityRequirementModel
{
Id = DataType.BUILDING_EyeOfAros,
Requirement = RequirementType.Production_Building
})
},
@@ -2632,7 +2624,7 @@ public class DATA
.AddPart(new EntityFactionModel { Faction = FactionType.Aru })
.AddPart(new EntityProductionModel { Alloy = 100, BuildTime = 25 })
.AddPart(new EntitySupplyModel { Takes = 6 })
.AddPart(new EntityRequirementModel { Requirement = RequirementType.Morph })
.AddPart(new EntityRequirementModel { Id = DataType.UNIT_RedSeer, Requirement = RequirementType.Morph })
.AddPart(new EntityVitalityModel { Health = 200, DefenseLayer = 60, Armor = ArmorType.Heavy })
.AddPart(new EntityMovementModel { Speed = 210, Movement = MovementType.Ground })
.AddPart(new EntityWeaponModel
@@ -2853,6 +2845,7 @@ public class DATA
.AddPart(new EntityFactionModel { Faction = FactionType.QRath })
.AddPart(new EntityRequirementModel
{
Id = DataType.BUILDING_Acropolis,
Requirement = RequirementType.Morph
})
.AddPart(new EntityProductionModel { Alloy = 75, BuildTime = 20, RequiresWorker = false })
@@ -3245,7 +3238,9 @@ public class DATA
.AddPart(new EntityInfoModel { Name = "Omnivore", Descriptive = DescriptiveType.Upgrade })
.AddPart(new EntityHotkeyModel { Hotkey = "Q", HotkeyGroup = "SHIFT" })
.AddPart(new EntityFactionModel { Faction = FactionType.Aru })
.AddPart(new EntityRequirementModel { Requirement = RequirementType.Morph })
.AddPart(new EntityRequirementModel {
Id = DataType.DEFENSE_Aerovore,
Requirement = RequirementType.Morph })
.AddPart(new EntityProductionModel { Alloy = 50, BuildTime = 18, RequiresWorker = false })
.AddPart(new EntityVitalityModel
{ Health = 400, DefenseLayer = 50, Armor = ArmorType.Heavy, IsStructure = true })
+1 -1
View File
@@ -165,7 +165,7 @@ public class EntityModel
}
public EntitySupplyModel Supply()
public EntitySupplyModel? Supply()
{
return ((EntitySupplyModel)EntityParts.Find(x => x.GetType() == typeof(EntitySupplyModel))!)!;
}