feat(EconomyComparison) Added new WIP Feature
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Model.BuildOrders;
|
||||
|
||||
public class BuildComparisonModel
|
||||
{
|
||||
public List<BuildOrderModel> Builds { get; set; } = new()
|
||||
{
|
||||
new BuildOrderModel(),
|
||||
new BuildOrderModel(),
|
||||
new BuildOrderModel()
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Model.Entity;
|
||||
using Model.Entity.Data;
|
||||
|
||||
namespace Model.BuildOrders;
|
||||
|
||||
public class BuildOrderModel
|
||||
{
|
||||
public BuildOrderModel()
|
||||
{
|
||||
Initialize(DataType.FACTION_QRath);
|
||||
}
|
||||
|
||||
public BuildOrderModel(string factionType)
|
||||
{
|
||||
Initialize(factionType);
|
||||
}
|
||||
|
||||
public string Name { get; set; } = "";
|
||||
public string Color { get; set; } = "red";
|
||||
public string Notes { get; set; } = @"";
|
||||
|
||||
public List<string> BuildTypes { get; set; } = new();
|
||||
@@ -18,6 +29,64 @@ public class BuildOrderModel
|
||||
public Dictionary<string, int> UniqueCompletedCount { get; set; } = new();
|
||||
public Dictionary<int, int> SupplyCountTimes { get; set; } = new();
|
||||
|
||||
public void Initialize(string faction)
|
||||
{
|
||||
string factionStartingTownHall = faction.Equals(DataType.FACTION_QRath) ? DataType.STARTING_TownHall_QRath :
|
||||
faction.Equals(DataType.FACTION_Aru) ? DataType.STARTING_TownHall_Aru : "";
|
||||
|
||||
if (factionStartingTownHall.Equals(""))
|
||||
{
|
||||
throw new Exception("Reminder to add support to new factions");
|
||||
}
|
||||
|
||||
StartedOrders = new Dictionary<int, List<EntityModel>>
|
||||
{
|
||||
{
|
||||
0,
|
||||
new List<EntityModel>
|
||||
{
|
||||
EntityModel.Get(DataType.STARTING_Bastion),
|
||||
EntityModel.Get(DataType.STARTING_TownHall_Aru)
|
||||
}
|
||||
}
|
||||
};
|
||||
CompletedOrders = new Dictionary<int, List<EntityModel>>
|
||||
{
|
||||
{
|
||||
0,
|
||||
new List<EntityModel>
|
||||
{
|
||||
EntityModel.Get(DataType.STARTING_Bastion),
|
||||
EntityModel.Get(DataType.STARTING_TownHall_Aru)
|
||||
}
|
||||
}
|
||||
};
|
||||
UniqueCompletedTimes = new Dictionary<string, int>
|
||||
{
|
||||
{
|
||||
DataType.STARTING_Bastion, 0
|
||||
},
|
||||
{
|
||||
DataType.STARTING_TownHall_Aru, 0
|
||||
}
|
||||
};
|
||||
UniqueCompletedCount = new Dictionary<string, int>
|
||||
{
|
||||
{
|
||||
DataType.STARTING_Bastion, 1
|
||||
},
|
||||
{
|
||||
DataType.STARTING_TownHall_Aru, 1
|
||||
}
|
||||
};
|
||||
SupplyCountTimes = new Dictionary<int, int>
|
||||
{
|
||||
{
|
||||
0, 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public List<EntityModel> GetHarvestersCompletedBefore(int interval)
|
||||
{
|
||||
return (from ordersAtTime in StartedOrders
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Model.Economy;
|
||||
using Model.Entity;
|
||||
using Model.Entity.Data;
|
||||
|
||||
namespace Model.BuildOrders;
|
||||
|
||||
public class BuildToCompareModel
|
||||
{
|
||||
public string Faction { get; set; }
|
||||
public EntityModel GetTownHallEntity => DATA.Get()[
|
||||
Faction.Equals(DataType.FACTION_QRath) ? DataType.BUILDING_Acropolis
|
||||
: DataType.BUILDING_GroveHeart];
|
||||
|
||||
public EntityModel GetTownHallMining2Entity => DATA.Get()[
|
||||
Faction.Equals(DataType.FACTION_QRath) ? DataType.BUPGRADE_MiningLevel2_QRath
|
||||
: DataType.BUPGRADE_MiningLevel2_Aru];
|
||||
|
||||
public EntityModel GetTownHallMining3Entity => DATA.Get()[
|
||||
Faction.Equals(DataType.FACTION_QRath) ? DataType.BUPGRADE_MiningLevel3_QRath
|
||||
: DataType.BUPGRADE_MiningLevel3_Aru];
|
||||
|
||||
|
||||
private int numberOfTownHallExpansions = 0;
|
||||
public int NumberOfTownHallExpansions
|
||||
{
|
||||
get => numberOfTownHallExpansions;
|
||||
set
|
||||
{
|
||||
if (value >= 0 && value < 6 && value != numberOfTownHallExpansions)
|
||||
{
|
||||
numberOfTownHallExpansions = value;
|
||||
while (TimeToBuildTownHall.Count < numberOfTownHallExpansions)
|
||||
{
|
||||
TimeToBuildTownHall.Add((TimeToBuildTownHall.Count + 1) * 30);
|
||||
}
|
||||
while (TimeToBuildTownHall.Count > numberOfTownHallExpansions)
|
||||
{
|
||||
TimeToBuildTownHall.Remove(TimeToBuildTownHall.Last());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<int> TimeToBuildTownHall { get; set; } = new();
|
||||
|
||||
public List<EconomyModel> EconomyOverTimeModel { get; set; } = new();
|
||||
|
||||
public BuildOrderModel BuildOrderModel { get; set; } = new();
|
||||
|
||||
public string ChartColor { get; set; }
|
||||
}
|
||||
@@ -9,122 +9,7 @@ namespace Model.Economy;
|
||||
|
||||
public class EconomyOverTimeModel
|
||||
{
|
||||
public int LastInterval { get; set; }
|
||||
|
||||
public List<EconomyModel> EconomyOverTime { get; set; } = new();
|
||||
|
||||
public void Calculate(BuildOrderModel buildOrder, int timing, int fromInterval)
|
||||
{
|
||||
if (EconomyOverTime == null)
|
||||
{
|
||||
EconomyOverTime = new List<EconomyModel>();
|
||||
for (var interval = 0; interval < timing; interval++)
|
||||
EconomyOverTime.Add(new EconomyModel { Interval = interval });
|
||||
}
|
||||
|
||||
if (EconomyOverTime.Count > timing) EconomyOverTime.RemoveRange(timing, EconomyOverTime.Count - timing);
|
||||
|
||||
while (EconomyOverTime.Count < timing)
|
||||
EconomyOverTime.Add(new EconomyModel { Interval = EconomyOverTime.Count - 1 });
|
||||
|
||||
for (var interval = fromInterval; interval < timing; interval++)
|
||||
{
|
||||
var economyAtSecond = EconomyOverTime[interval];
|
||||
if (interval > 0)
|
||||
{
|
||||
economyAtSecond.Alloy = EconomyOverTime[interval - 1].Alloy;
|
||||
economyAtSecond.Ether = EconomyOverTime[interval - 1].Ether;
|
||||
economyAtSecond.WorkerCount = EconomyOverTime[interval - 1].WorkerCount;
|
||||
economyAtSecond.BusyWorkerCount = EconomyOverTime[interval - 1].BusyWorkerCount;
|
||||
economyAtSecond.CreatingWorkerCount = EconomyOverTime[interval - 1].CreatingWorkerCount;
|
||||
economyAtSecond.Harvesters = EconomyOverTime[interval - 1].Harvesters.ToList();
|
||||
economyAtSecond.CreatingWorkerDelays = EconomyOverTime[interval - 1].CreatingWorkerDelays.ToList();
|
||||
}
|
||||
|
||||
economyAtSecond.Interval = interval;
|
||||
|
||||
// Add funds
|
||||
float freeWorkers = economyAtSecond.WorkerCount - economyAtSecond.BusyWorkerCount;
|
||||
var workersNeeded = 0;
|
||||
|
||||
economyAtSecond.Harvesters =
|
||||
(from harvester in buildOrder.GetHarvestersCompletedBefore(interval)
|
||||
select harvester).ToList();
|
||||
|
||||
// Add funds
|
||||
foreach (var entity in economyAtSecond.Harvesters)
|
||||
{
|
||||
var harvester = entity.Harvest();
|
||||
if (harvester.RequiresWorker)
|
||||
if (harvester.Resource == ResourceType.Alloy)
|
||||
{
|
||||
var usedWorkers = Math.Min(harvester.Slots, freeWorkers);
|
||||
economyAtSecond.Alloy += harvester.HarvestedPerInterval * usedWorkers;
|
||||
freeWorkers -= usedWorkers;
|
||||
|
||||
if (usedWorkers < harvester.Slots) workersNeeded += 1;
|
||||
}
|
||||
|
||||
if (harvester.RequiresWorker == false)
|
||||
{
|
||||
if (harvester.Resource == ResourceType.Ether)
|
||||
economyAtSecond.Ether += harvester.HarvestedPerInterval * harvester.Slots;
|
||||
|
||||
if (harvester.Resource == ResourceType.Alloy)
|
||||
economyAtSecond.Alloy += harvester.HarvestedPerInterval * harvester.Slots;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new worker
|
||||
if (economyAtSecond.CreatingWorkerCount > 0)
|
||||
for (var i = 0; i < economyAtSecond.CreatingWorkerDelays.Count; i++)
|
||||
if (economyAtSecond.CreatingWorkerDelays[i] > 0)
|
||||
{
|
||||
if (economyAtSecond.Alloy > 2.5f)
|
||||
{
|
||||
economyAtSecond.Alloy -= 2.5f;
|
||||
economyAtSecond.CreatingWorkerDelays[i]--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
economyAtSecond.CreatingWorkerCount -= 1;
|
||||
economyAtSecond.WorkerCount += 1;
|
||||
economyAtSecond.CreatingWorkerDelays.Remove(i);
|
||||
i--;
|
||||
}
|
||||
|
||||
if (workersNeeded > economyAtSecond.CreatingWorkerCount)
|
||||
{
|
||||
economyAtSecond.CreatingWorkerCount += 1;
|
||||
economyAtSecond.CreatingWorkerDelays.Add(50);
|
||||
}
|
||||
|
||||
// Remove Funds from Build Order
|
||||
if (buildOrder.StartedOrders.TryGetValue(interval, out var ordersAtTime))
|
||||
foreach (var order in ordersAtTime)
|
||||
{
|
||||
var foundEntity = EntityModel.GetDictionary()[order.DataType];
|
||||
var production = foundEntity.Production();
|
||||
|
||||
if (production != null)
|
||||
{
|
||||
economyAtSecond.Alloy -= production.Alloy;
|
||||
economyAtSecond.Ether -= production.Ether;
|
||||
var finishedAt = interval + production.BuildTime;
|
||||
|
||||
if (production.RequiresWorker) economyAtSecond.BusyWorkerCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle new entities
|
||||
if (buildOrder.StartedOrders.TryGetValue(interval, out var ordersCompletedAtTime))
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -55,7 +55,6 @@ public class NoteContentModel
|
||||
cleanUp = cleanUp.Trim();
|
||||
cleanUp = cleanUp.Replace(" ", "-");
|
||||
foundHeaders.Add(new SearchPointModel { Title = capture.ToString().Trim(), Href = cleanUp });
|
||||
Console.WriteLine($"Capture: {cleanUp}");
|
||||
}
|
||||
|
||||
return foundHeaders;
|
||||
|
||||
Reference in New Issue
Block a user