Browse Source

Harvest points can now be depleted

main
Jonathan 11 months ago
parent
commit
826717c47f
  1. 3
      IGP/Pages/BuildCalculator/BuildCalculatorPage.razor
  2. 1
      IGP/Pages/BuildCalculator/Parts/FilterComponent.razor
  3. 2
      IGP/Pages/BuildCalculator/Parts/HighlightsComponent.razor
  4. 4
      IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor
  5. 4
      IGP/Pages/DataTables/DataTablesPage.razor
  6. 2
      IGP/Pages/HarassCalculatorPage.razor
  7. 3
      IGP/Program.cs
  8. 2
      Model/BuildOrders/BuildToCompareModel.cs
  9. 8
      Model/Entity/Data/Ids_Entity.cs
  10. 11
      Model/Entity/Parts/EntityHarvestModel.cs
  11. 2
      Model/Hotkeys/HotKeyType.cs
  12. 7
      Model/Hotkeys/HotkeyModel.cs
  13. 1
      Services/IServices.cs
  14. 11
      Services/Immortal/BuildOrderService.cs
  15. 29
      Services/Immortal/EconomyService.cs

3
IGP/Pages/BuildCalculator/BuildCalculatorPage.razor

@ -27,7 +27,8 @@
Currently not considering running out of alloy and ether to harvest. Currently not considering running out of alloy and ether to harvest.
<br/> <br/>
<br/> <br/>
Build Calculator was built based on a much older version of the game and was only quickly modified for the June 2025 Playtest version, so the above disclaimer is only more true. Build Calculator was built based on a much older version of the game and was only quickly modified for the
June 2025 Playtest version, so the above disclaimer is only more true.
<br/> <br/>
Expect even more oddities and invalid data then the above warning implies. Expect even more oddities and invalid data then the above warning implies.
</Message> </Message>

1
IGP/Pages/BuildCalculator/Parts/FilterComponent.razor

@ -32,7 +32,6 @@
} }
@if (FilterService.GetFaction() == DataType.FACTION_Aru) @if (FilterService.GetFaction() == DataType.FACTION_Aru)
{ {
<option value="@DataType.IMMORTAL_Atzlan" <option value="@DataType.IMMORTAL_Atzlan"
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Atzlan))"> selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Atzlan))">
Atzlan Atzlan

2
IGP/Pages/BuildCalculator/Parts/HighlightsComponent.razor

@ -42,7 +42,7 @@
} }
} }
</div> </div>
<div> <div>
<div>Depleted</div> <div>Depleted</div>
//TODO WIP //TODO WIP

4
IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor

@ -343,10 +343,10 @@
{ {
var hotkey = KeyService.GetHotkey(); var hotkey = KeyService.GetHotkey();
if(hotkey is "`") if (hotkey is "`")
HandleCancelEntity(); HandleCancelEntity();
if (EntityFromKey(hotkey, out var entity)) if (EntityFromKey(hotkey, out var entity))
return; return;
if (BuildOrderService.Add(entity!, EconomyService)) if (BuildOrderService.Add(entity!, EconomyService))

4
IGP/Pages/DataTables/DataTablesPage.razor

@ -6,14 +6,14 @@
<LayoutLargeContentComponent> <LayoutLargeContentComponent>
<WebsiteTitleComponent>Data Tables</WebsiteTitleComponent> <WebsiteTitleComponent>Data Tables</WebsiteTitleComponent>
<AlertComponent Type="@SeverityType.Warning"> <AlertComponent Type="@SeverityType.Warning">
<Title>Errors Present</Title> <Title>Errors Present</Title>
<Message> <Message>
Incomplete feature for easily comparing unit stats. Incomplete feature for easily comparing unit stats.
</Message> </Message>
</AlertComponent> </AlertComponent>
<MudTabs Elevation="2"> <MudTabs Elevation="2">
<MudTabPanel Text="Attacks"> <MudTabPanel Text="Attacks">
<WeaponTable/> <WeaponTable/>

2
IGP/Pages/HarassCalculatorPage.razor

@ -8,7 +8,7 @@
<LayoutMediumContentComponent> <LayoutMediumContentComponent>
<WebsiteTitleComponent>Harass Calculator</WebsiteTitleComponent> <WebsiteTitleComponent>Harass Calculator</WebsiteTitleComponent>
<AlertComponent Type="@SeverityType.Warning"> <AlertComponent Type="@SeverityType.Warning">
<Title>Might be out of date</Title> <Title>Might be out of date</Title>
<Message> <Message>

3
IGP/Program.cs

@ -77,5 +77,4 @@ builder.Services.AddScoped(sp => new HttpClient
builder.Services.AddMudServices(); builder.Services.AddMudServices();
await builder.Build().RunAsync(); await builder.Build().RunAsync();

2
Model/BuildOrders/BuildToCompareModel.cs

@ -20,7 +20,7 @@ public class BuildToCompareModel
Faction.Equals(DataType.FACTION_QRath) Faction.Equals(DataType.FACTION_QRath)
? DataType.BUPGRADE_MiningLevel2_QRath ? DataType.BUPGRADE_MiningLevel2_QRath
: DataType.BUPGRADE_MiningLevel2_Aru]; : DataType.BUPGRADE_MiningLevel2_Aru];
public int NumberOfTownHallExpansions public int NumberOfTownHallExpansions
{ {
get => numberOfTownHallExpansions; get => numberOfTownHallExpansions;

8
Model/Entity/Data/Ids_Entity.cs

@ -85,13 +85,13 @@ public static class DataType
public static string BUILDING_ApostleOfBinding = nameof(BUILDING_ApostleOfBinding); public static string BUILDING_ApostleOfBinding = nameof(BUILDING_ApostleOfBinding);
public static string BUILDING_GroveHeart = nameof(BUILDING_GroveHeart); public static string BUILDING_GroveHeart = nameof(BUILDING_GroveHeart);
public static string BUILDING_EtherMaw = nameof(BUILDING_EtherMaw); public static string BUILDING_EtherMaw = nameof(BUILDING_EtherMaw);
public static string BUPGRADE_MiningLevel2_QRath = nameof(BUPGRADE_MiningLevel2_QRath); public static string BUPGRADE_MiningLevel2_QRath = nameof(BUPGRADE_MiningLevel2_QRath);
public static string BUPGRADE_MiningLevel2_Aru = nameof(BUPGRADE_MiningLevel2_Aru); public static string BUPGRADE_MiningLevel2_Aru = nameof(BUPGRADE_MiningLevel2_Aru);
public static string CONVERSION_EtherSruge_QRath = nameof(CONVERSION_EtherSruge_QRath); public static string CONVERSION_EtherSruge_QRath = nameof(CONVERSION_EtherSruge_QRath);
public static string CONVERSION_EtherSruge_Aru = nameof(CONVERSION_EtherSruge_Aru); public static string CONVERSION_EtherSruge_Aru = nameof(CONVERSION_EtherSruge_Aru);
public static string BUPGRADE_GodHeart = nameof(BUPGRADE_GodHeart); public static string BUPGRADE_GodHeart = nameof(BUPGRADE_GodHeart);
public static string BUPGRADE_Omnivore = nameof(BUPGRADE_Omnivore); public static string BUPGRADE_Omnivore = nameof(BUPGRADE_Omnivore);
public static string BUILDING_LegionHall = nameof(BUILDING_LegionHall); public static string BUILDING_LegionHall = nameof(BUILDING_LegionHall);
@ -270,10 +270,10 @@ public static class DataType
public static string VANGUARD_WhiteWoodReaper_Xol = nameof(VANGUARD_WhiteWoodReaper_Xol); public static string VANGUARD_WhiteWoodReaper_Xol = nameof(VANGUARD_WhiteWoodReaper_Xol);
public static string VANGUARD_DreadSister_Mala = nameof(VANGUARD_DreadSister_Mala); public static string VANGUARD_DreadSister_Mala = nameof(VANGUARD_DreadSister_Mala);
public static string VANGUARD_Incubator_Mala = nameof(VANGUARD_Incubator_Mala); public static string VANGUARD_Incubator_Mala = nameof(VANGUARD_Incubator_Mala);
public static string WORKER_Mote = nameof(WORKER_Mote); public static string WORKER_Mote = nameof(WORKER_Mote);
public static string WORKER_Symbiote = nameof(WORKER_Symbiote); public static string WORKER_Symbiote = nameof(WORKER_Symbiote);
public static string UNIT_Sipari = nameof(UNIT_Sipari); public static string UNIT_Sipari = nameof(UNIT_Sipari);
public static string UNIT_Zephyr = nameof(UNIT_Zephyr); public static string UNIT_Zephyr = nameof(UNIT_Zephyr);
public static string UNIT_Magi = nameof(UNIT_Magi); public static string UNIT_Magi = nameof(UNIT_Magi);

11
Model/Entity/Parts/EntityHarvestModel.cs

@ -11,4 +11,15 @@ public class EntityHarvestModel : IEntityPartInterface
public float HarvestDelay { get; set; } = 1; public float HarvestDelay { get; set; } = 1;
public int TotalAmount { get; set; } public int TotalAmount { get; set; }
public bool RequiresWorker { get; set; } public bool RequiresWorker { get; set; }
public float StartedAt { get; set; }
public bool IsDepleted(float interval)
{
var lifeTime = interval - StartedAt;
var totalHarvested = (lifeTime - 1) * HarvestedPerInterval;
return totalHarvested > TotalAmount;
}
} }

2
Model/Hotkeys/HotKeyType.cs

@ -9,7 +9,7 @@ public enum KeyType
Train, Train,
Research, Research,
Construct, Construct,
Cancel, Cancel,
Advance, Advance,
Economy, Economy,

7
Model/Hotkeys/HotkeyModel.cs

@ -19,16 +19,13 @@ public class HotkeyModel
return KeyType == KeyType.Action ? "#404146" return KeyType == KeyType.Action ? "#404146"
: KeyType == KeyType.Cancel ? "#621b1b" : KeyType == KeyType.Cancel ? "#621b1b"
: KeyType == KeyType.ControlGroup ? "#443512" : KeyType == KeyType.ControlGroup ? "#443512"
: KeyType == KeyType.Army ? "#443512" : KeyType == KeyType.Army ? "#443512"
: KeyType == KeyType.Train ? "#124443" : KeyType == KeyType.Train ? "#124443"
: KeyType == KeyType.Research ? "#221244" : KeyType == KeyType.Research ? "#221244"
: KeyType == KeyType.Construct ? "#122844" : KeyType == KeyType.Construct ? "#122844"
: KeyType == KeyType.Pyre ? "#441212" : KeyType == KeyType.Pyre ? "#441212"
: KeyType == KeyType.Advance ? "#23262c" : KeyType == KeyType.Advance ? "#23262c"
: KeyType == KeyType.Economy ? "#262c23" : KeyType == KeyType.Economy ? "#262c23"
: "#37393F"; : "#37393F";
} }
@ -78,7 +75,7 @@ public class HotkeyModel
PositionX = 0, PositionX = 0,
PositionY = 0 PositionY = 0
}, },
new() new()
{ {
KeyText = "TAB", KeyText = "TAB",

1
Services/IServices.cs

@ -136,7 +136,6 @@ public interface IWebsiteService
public bool IsLoaded(); public bool IsLoaded();
} }
public interface INoteService public interface INoteService
{ {
public List<NoteContentModel> NoteContentModels { get; set; } public List<NoteContentModel> NoteContentModels { get; set; }

11
Services/Immortal/BuildOrderService.cs

@ -172,7 +172,7 @@ public class BuildOrderService : IBuildOrderService
if (supply == null || supply.Takes.Equals(0)) return 0; if (supply == null || supply.Takes.Equals(0)) return 0;
foreach (var supplyAtTime in foreach (var supplyAtTime in
_buildOrder.SupplyCountTimes _buildOrder.SupplyCountTimes
.Where(supplyAtTime => supply.Takes + _buildOrder.CurrentSupplyUsed <= supplyAtTime.Key)) .Where(supplyAtTime => supply.Takes + _buildOrder.CurrentSupplyUsed <= supplyAtTime.Key))
return supplyAtTime.Value; return supplyAtTime.Value;
@ -198,7 +198,7 @@ public class BuildOrderService : IBuildOrderService
public void RemoveLast() public void RemoveLast()
{ {
if (_buildOrder.StartedOrders.Keys.Count <= 1) return; if (_buildOrder.StartedOrders.Keys.Count <= 1) return;
if (_buildOrder.StartedOrders.Count == 0) if (_buildOrder.StartedOrders.Count == 0)
{ {
_buildOrder.StartedOrders.Remove(_buildOrder.StartedOrders.Last().Key); _buildOrder.StartedOrders.Remove(_buildOrder.StartedOrders.Last().Key);
@ -357,9 +357,10 @@ public class BuildOrderService : IBuildOrderService
while (true) while (true)
{ {
var usedSlots = 0; var usedSlots = 0;
foreach (var used in foreach (var used in
_buildOrder.TrainingCapacityUsed _buildOrder.TrainingCapacityUsed
.Where(used => checkedInterval >= used.StartingUsageTime && checkedInterval < used.StopUsageTime)) .Where(used =>
checkedInterval >= used.StartingUsageTime && checkedInterval < used.StopUsageTime))
{ {
usedSlots += used.UsedSlots; usedSlots += used.UsedSlots;
var duration = used.StopUsageTime - used.StartingUsageTime; var duration = used.StopUsageTime - used.StartingUsageTime;
@ -399,7 +400,7 @@ public class BuildOrderService : IBuildOrderService
if (!(economyAtSecond.Alloy >= production.Alloy) if (!(economyAtSecond.Alloy >= production.Alloy)
|| !(economyAtSecond.Ether >= production.Ether) || !(economyAtSecond.Ether >= production.Ether)
|| !(economyAtSecond.Pyre >= production.Pyre)) continue; || !(economyAtSecond.Pyre >= production.Pyre)) continue;
atInterval = interval; atInterval = interval;
if (entity.EntityType != EntityType.Army) atInterval += _timingService.BuildingInputDelay; if (entity.EntityType != EntityType.Army) atInterval += _timingService.BuildingInputDelay;

29
Services/Immortal/EconomyService.cs

@ -67,8 +67,8 @@ public class EconomyService : IEconomyService
public EconomyModel GetEconomy(int atInterval) public EconomyModel GetEconomy(int atInterval)
{ {
return atInterval >= buildEconomyOverTime.Count return atInterval >= buildEconomyOverTime.Count
? buildEconomyOverTime.Last() ? buildEconomyOverTime.Last()
: buildEconomyOverTime[atInterval]; : buildEconomyOverTime[atInterval];
} }
@ -84,10 +84,12 @@ public class EconomyService : IEconomyService
EconomyModel economyAtSecond) EconomyModel economyAtSecond)
{ {
if (!buildOrder.CompletedOrders.TryGetValue(interval, out var completedAtInterval)) return; if (!buildOrder.CompletedOrders.TryGetValue(interval, out var completedAtInterval)) return;
foreach (var newEntity in completedAtInterval) 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(); var production = newEntity.Production();
if (production is { RequiresWorker: true }) economyAtSecond.BusyWorkerCount -= 1; 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; if (!buildOrder.StartedOrders.TryGetValue(interval, out var ordersAtTime)) return;
foreach (var production in foreach (var production in
ordersAtTime.Select(order => EntityModel.GetDictionary()[order.DataType]) ordersAtTime.Select(order => EntityModel.GetDictionary()[order.DataType])
.Select(foundEntity => foundEntity.Production()) .Select(foundEntity => foundEntity.Production())
.OfType<EntityProductionModel>()) .OfType<EntityProductionModel>())
@ -107,7 +109,7 @@ public class EconomyService : IEconomyService
economyAtSecond.Alloy -= production.Alloy; economyAtSecond.Alloy -= production.Alloy;
economyAtSecond.Ether -= production.Ether; economyAtSecond.Ether -= production.Ether;
economyAtSecond.Pyre -= production.Pyre; economyAtSecond.Pyre -= production.Pyre;
if (production.RequiresWorker) economyAtSecond.BusyWorkerCount += 1; if (production.RequiresWorker) economyAtSecond.BusyWorkerCount += 1;
if (production.ConsumesWorker) economyAtSecond.WorkerCount -= 1; if (production.ConsumesWorker) economyAtSecond.WorkerCount -= 1;
} }
@ -116,7 +118,7 @@ public class EconomyService : IEconomyService
private static void MakeNeededNewWorkersRequests(int workersNeeded, EconomyModel economyAtSecond) private static void MakeNeededNewWorkersRequests(int workersNeeded, EconomyModel economyAtSecond)
{ {
if (workersNeeded <= economyAtSecond.CreatingWorkerCount) return; if (workersNeeded <= economyAtSecond.CreatingWorkerCount) return;
economyAtSecond.CreatingWorkerCount += 1; economyAtSecond.CreatingWorkerCount += 1;
economyAtSecond.CreatingWorkerDelays.Add(20); economyAtSecond.CreatingWorkerDelays.Add(20);
} }
@ -129,12 +131,12 @@ public class EconomyService : IEconomyService
var createdWorkers = 0; var createdWorkers = 0;
if (economyAtSecond.CreatingWorkerCount <= 0) return createdWorkers; if (economyAtSecond.CreatingWorkerCount <= 0) return createdWorkers;
for (var i = 0; i < economyAtSecond.CreatingWorkerDelays.Count; i++) for (var i = 0; i < economyAtSecond.CreatingWorkerDelays.Count; i++)
if (economyAtSecond.CreatingWorkerDelays[i] > 0) if (economyAtSecond.CreatingWorkerDelays[i] > 0)
{ {
if (!(economyAtSecond.Alloy > 2.5f)) continue; if (!(economyAtSecond.Alloy > 2.5f)) continue;
economyAtSecond.Alloy -= 2.5f; economyAtSecond.Alloy -= 2.5f;
economyAtSecond.CreatingWorkerDelays[i]--; economyAtSecond.CreatingWorkerDelays[i]--;
} }
@ -157,9 +159,13 @@ public class EconomyService : IEconomyService
{ {
var workersNeeded = 0; var workersNeeded = 0;
foreach (var harvesterPoint in
foreach (var harvesterPoint in
economyAtSecond.HarvestPoints.Select(entity => entity.Harvest())) economyAtSecond.HarvestPoints.Select(entity => entity.Harvest()))
{ {
if (harvesterPoint.IsDepleted(economyAtSecond.Interval))
continue;
switch (harvesterPoint.RequiresWorker) switch (harvesterPoint.RequiresWorker)
{ {
case true: case true:
@ -167,9 +173,10 @@ public class EconomyService : IEconomyService
if (harvesterPoint.Resource == ResourceType.Alloy) if (harvesterPoint.Resource == ResourceType.Alloy)
{ {
var usedWorkers = Math.Min(harvesterPoint.Slots, freeWorkers); var usedWorkers = Math.Min(harvesterPoint.Slots, freeWorkers);
economyAtSecond.Alloy += harvesterPoint.HarvestedPerInterval * usedWorkers; economyAtSecond.Alloy += harvesterPoint.HarvestedPerInterval * usedWorkers;
economyAtSecond.AlloyIncome += harvesterPoint.HarvestedPerInterval * usedWorkers; economyAtSecond.AlloyIncome += harvesterPoint.HarvestedPerInterval * usedWorkers;
freeWorkers -= usedWorkers; freeWorkers -= usedWorkers;
if (usedWorkers < harvesterPoint.Slots) workersNeeded += 1; if (usedWorkers < harvesterPoint.Slots) workersNeeded += 1;

Loading…
Cancel
Save