feat(Documents) Notes/Docs page improvements and warning cleanup
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Model.Immortal.BuildOrders;
|
||||
using Model.Immortal.Entity;
|
||||
using Model.Immortal.Types;
|
||||
using Model.BuildOrders;
|
||||
using Model.Entity;
|
||||
using Model.Types;
|
||||
|
||||
namespace Model.Immortal.Economy;
|
||||
namespace Model.Economy;
|
||||
|
||||
public class EconomyOverTimeModel {
|
||||
public class EconomyOverTimeModel
|
||||
{
|
||||
public List<EconomyModel> EconomyOverTime { get; set; } = new();
|
||||
|
||||
public void Calculate(BuildOrderModel buildOrder, int timing, int fromInterval) {
|
||||
if (EconomyOverTime == null) {
|
||||
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 });
|
||||
@@ -22,9 +25,11 @@ public class EconomyOverTimeModel {
|
||||
while (EconomyOverTime.Count < timing)
|
||||
EconomyOverTime.Add(new EconomyModel { Interval = EconomyOverTime.Count - 1 });
|
||||
|
||||
for (var interval = fromInterval; interval < timing; interval++) {
|
||||
for (var interval = fromInterval; interval < timing; interval++)
|
||||
{
|
||||
var economyAtSecond = EconomyOverTime[interval];
|
||||
if (interval > 0) {
|
||||
if (interval > 0)
|
||||
{
|
||||
economyAtSecond.Alloy = EconomyOverTime[interval - 1].Alloy;
|
||||
economyAtSecond.Ether = EconomyOverTime[interval - 1].Ether;
|
||||
economyAtSecond.WorkerCount = EconomyOverTime[interval - 1].WorkerCount;
|
||||
@@ -45,10 +50,12 @@ public class EconomyOverTimeModel {
|
||||
select harvester).ToList();
|
||||
|
||||
// Add funds
|
||||
foreach (var entity in economyAtSecond.Harvesters) {
|
||||
foreach (var entity in economyAtSecond.Harvesters)
|
||||
{
|
||||
var harvester = entity.Harvest();
|
||||
if (harvester.RequiresWorker)
|
||||
if (harvester.Resource == ResourceType.Alloy) {
|
||||
if (harvester.Resource == ResourceType.Alloy)
|
||||
{
|
||||
var usedWorkers = Math.Min(harvester.Slots, freeWorkers);
|
||||
economyAtSecond.Alloy += harvester.HarvestedPerInterval * usedWorkers;
|
||||
freeWorkers -= usedWorkers;
|
||||
@@ -56,7 +63,8 @@ public class EconomyOverTimeModel {
|
||||
if (usedWorkers < harvester.Slots) workersNeeded += 1;
|
||||
}
|
||||
|
||||
if (harvester.RequiresWorker == false) {
|
||||
if (harvester.RequiresWorker == false)
|
||||
{
|
||||
if (harvester.Resource == ResourceType.Ether)
|
||||
economyAtSecond.Ether += harvester.HarvestedPerInterval * harvester.Slots;
|
||||
|
||||
@@ -68,20 +76,24 @@ public class EconomyOverTimeModel {
|
||||
// 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) {
|
||||
if (economyAtSecond.CreatingWorkerDelays[i] > 0)
|
||||
{
|
||||
if (economyAtSecond.Alloy > 2.5f)
|
||||
{
|
||||
economyAtSecond.Alloy -= 2.5f;
|
||||
economyAtSecond.CreatingWorkerDelays[i]--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
economyAtSecond.CreatingWorkerCount -= 1;
|
||||
economyAtSecond.WorkerCount += 1;
|
||||
economyAtSecond.CreatingWorkerDelays.Remove(i);
|
||||
i--;
|
||||
}
|
||||
|
||||
if (workersNeeded > economyAtSecond.CreatingWorkerCount) {
|
||||
if (workersNeeded > economyAtSecond.CreatingWorkerCount)
|
||||
{
|
||||
economyAtSecond.CreatingWorkerCount += 1;
|
||||
economyAtSecond.CreatingWorkerDelays.Add(50);
|
||||
}
|
||||
@@ -89,11 +101,13 @@ public class EconomyOverTimeModel {
|
||||
// Remove Funds from Build Order
|
||||
var ordersAtTime = buildOrder.GetOrdersAt(interval);
|
||||
|
||||
foreach (var order in ordersAtTime) {
|
||||
foreach (var order in ordersAtTime)
|
||||
{
|
||||
var foundEntity = EntityModel.GetDictionary()[order.DataType];
|
||||
var production = foundEntity.Production();
|
||||
|
||||
if (production != null) {
|
||||
if (production != null)
|
||||
{
|
||||
economyAtSecond.Alloy -= production.Alloy;
|
||||
economyAtSecond.Ether -= production.Ether;
|
||||
var finishedAt = interval + production.BuildTime;
|
||||
@@ -104,7 +118,8 @@ public class EconomyOverTimeModel {
|
||||
|
||||
// Handle new entities
|
||||
var completedAtInterval = buildOrder.GetCompletedAt(interval);
|
||||
foreach (var newEntity in completedAtInterval) {
|
||||
foreach (var newEntity in completedAtInterval)
|
||||
{
|
||||
var harvest = newEntity;
|
||||
if (harvest != null) economyAtSecond.Harvesters.Add(harvest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user