Browse Source

feat(BuildCalc) Add +income to calculator info

main
Jonathan McCaffrey 4 years ago
parent
commit
0caa61f42e
  1. 2
      IGP/Pages/BuildCalculator/BuildCalculatorPage.razor
  2. 11
      IGP/Pages/BuildCalculator/Parts/BankComponent.razor
  3. 2
      IGP/wwwroot/generated/Variables.json
  4. 2
      Model/Economy/EconomyModel.cs
  5. 8
      Services/Immortal/EconomyService.cs

2
IGP/Pages/BuildCalculator/BuildCalculatorPage.razor

@ -23,6 +23,8 @@
<Title>Work In Progress and Not Fully Tested</Title> <Title>Work In Progress and Not Fully Tested</Title>
<Message> <Message>
Build Calculator hasn't been thoroughly tested. Bugs and inaccurate results assumed. Build Calculator hasn't been thoroughly tested. Bugs and inaccurate results assumed.
<br/>
Currently not considering running out of alloy and ether to harvest.
</Message> </Message>
</AlertComponent> </AlertComponent>

11
IGP/Pages/BuildCalculator/Parts/BankComponent.razor

@ -7,14 +7,14 @@
<div class="bankContainer"> <div class="bankContainer">
<FormDisplayComponent Label="Time"> <FormDisplayComponent Label="Time">
<Display>@BuildOrderService.GetLastRequestInterval() | T @Interval.ToTime(BuildOrderService.GetLastRequestInterval())</Display> <Display>@(BuildOrderService.GetLastRequestInterval() + 1) | T @Interval.ToTime(BuildOrderService.GetLastRequestInterval() + 1)</Display>
</FormDisplayComponent> </FormDisplayComponent>
<div class="bankRow"> <div class="bankRow">
<FormDisplayComponent Label="Alloy"> <FormDisplayComponent Label="Alloy">
<Display>@_economy.Alloy</Display> <Display>@_economy.Alloy +@_economy.AlloyIncome</Display>
</FormDisplayComponent> </FormDisplayComponent>
<FormDisplayComponent Label="Ether"> <FormDisplayComponent Label="Ether">
<Display>@_economy.Ether</Display> <Display>@Math.Round(_economy.Ether) +@Math.Round(_economy.EtherIncome)</Display>
</FormDisplayComponent> </FormDisplayComponent>
</div> </div>
<div class="bankRow"> <div class="bankRow">
@ -77,6 +77,9 @@
{ {
base.OnInitialized(); base.OnInitialized();
BuildOrderService.Subscribe(OnBuildOrderChanged); BuildOrderService.Subscribe(OnBuildOrderChanged);
_economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval() + 1);
} }
protected override bool ShouldRender() protected override bool ShouldRender()
@ -102,7 +105,7 @@
void OnBuildOrderChanged() void OnBuildOrderChanged()
{ {
_economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval()); _economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval() + 1);
var ordersOverTime = BuildOrderService.GetOrders(); var ordersOverTime = BuildOrderService.GetOrders();

2
IGP/wwwroot/generated/Variables.json

@ -1 +1 @@
[{"Key":"GamePatch","Value":"v0.0.6.9553a"},{"Key":"LastUpdated","Value":"May 02, 2022"}] [{"Key":"GamePatch","Value":"v0.0.6.9553a"},{"Key":"LastUpdated","Value":"May 03, 2022"}]

2
Model/Economy/EconomyModel.cs

@ -7,7 +7,9 @@ public class EconomyModel
{ {
public int Interval { get; set; } = 0; public int Interval { get; set; } = 0;
public float Alloy { get; set; } = 0; public float Alloy { get; set; } = 0;
public float AlloyIncome { get; set; } = 0;
public float Ether { get; set; } = 0; public float Ether { get; set; } = 0;
public float EtherIncome { get; set; } = 0;
public float Pyre { get; set; } = 0; public float Pyre { get; set; } = 0;
public int Supply { get; set; } = 0; public int Supply { get; set; } = 0;
public int WorkerCount { get; set; } = 6; public int WorkerCount { get; set; } = 6;

8
Services/Immortal/EconomyService.cs

@ -173,6 +173,8 @@ public class EconomyService : IEconomyService
{ {
var usedWorkers = Math.Min(harvester.Slots, freeWorkers); var usedWorkers = Math.Min(harvester.Slots, freeWorkers);
economyAtSecond.Alloy += harvester.HarvestedPerInterval * usedWorkers; economyAtSecond.Alloy += harvester.HarvestedPerInterval * usedWorkers;
economyAtSecond.AlloyIncome += harvester.HarvestedPerInterval * usedWorkers;
freeWorkers -= usedWorkers; freeWorkers -= usedWorkers;
if (usedWorkers < harvester.Slots) workersNeeded += 1; if (usedWorkers < harvester.Slots) workersNeeded += 1;
@ -181,10 +183,16 @@ public class EconomyService : IEconomyService
if (harvester.RequiresWorker == false) if (harvester.RequiresWorker == false)
{ {
if (harvester.Resource == ResourceType.Ether) if (harvester.Resource == ResourceType.Ether)
{
economyAtSecond.Ether += harvester.HarvestedPerInterval * harvester.Slots; economyAtSecond.Ether += harvester.HarvestedPerInterval * harvester.Slots;
economyAtSecond.EtherIncome += harvester.HarvestedPerInterval * harvester.Slots;
}
if (harvester.Resource == ResourceType.Alloy) if (harvester.Resource == ResourceType.Alloy)
{
economyAtSecond.Alloy += harvester.HarvestedPerInterval * harvester.Slots; economyAtSecond.Alloy += harvester.HarvestedPerInterval * harvester.Slots;
economyAtSecond.AlloyIncome += harvester.HarvestedPerInterval * harvester.Slots;
}
} }
} }

Loading…
Cancel
Save