Skip to content

Commit

Permalink
Merge pull request #166 from polygamma/develop
Browse files Browse the repository at this point in the history
Fix wrong calculations for building of next deposit
  • Loading branch information
kokiddp authored Oct 31, 2023
2 parents 34be02e + d8ad2d2 commit e271611
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions TBot/Includes/CalculationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2971,9 +2971,9 @@ public long CalcDepositCapacity(int level) {
public bool ShouldBuildMetalStorage(Planet planet, int maxLevel, int speedFactor, int hours = 12, float ratio = 1, Researches researches = null, CharacterClass playerClass = CharacterClass.NoClass, bool hasGeologist = false, bool hasStaff = false, bool forceIfFull = false) {
long metalProduction = CalcMetalProduction(planet, speedFactor, ratio, researches, playerClass, hasGeologist, hasStaff);
long metalCapacity = CalcDepositCapacity(planet.Buildings.MetalStorage);
if (forceIfFull && planet.Resources.Metal >= metalCapacity && GetNextLevel(planet, Buildables.MetalStorage) < maxLevel)
if (forceIfFull && planet.Resources.Metal >= metalCapacity && GetNextLevel(planet, Buildables.MetalStorage) <= maxLevel)
return true;
if (metalCapacity < hours * metalProduction && GetNextLevel(planet, Buildables.MetalStorage) < maxLevel)
if (metalCapacity < hours * metalProduction && GetNextLevel(planet, Buildables.MetalStorage) <= maxLevel)
return true;
else
return false;
Expand All @@ -2982,9 +2982,9 @@ public bool ShouldBuildMetalStorage(Planet planet, int maxLevel, int speedFactor
public bool ShouldBuildCrystalStorage(Planet planet, int maxLevel, int speedFactor, int hours = 12, float ratio = 1, Researches researches = null, CharacterClass playerClass = CharacterClass.NoClass, bool hasGeologist = false, bool hasStaff = false, bool forceIfFull = false) {
long crystalProduction = CalcCrystalProduction(planet, speedFactor, ratio, researches, playerClass, hasGeologist, hasStaff);
long crystalCapacity = CalcDepositCapacity(planet.Buildings.CrystalStorage);
if (forceIfFull && planet.Resources.Crystal >= crystalCapacity && GetNextLevel(planet, Buildables.CrystalStorage) < maxLevel)
if (forceIfFull && planet.Resources.Crystal >= crystalCapacity && GetNextLevel(planet, Buildables.CrystalStorage) <= maxLevel)
return true;
if (crystalCapacity < hours * crystalProduction && GetNextLevel(planet, Buildables.CrystalStorage) < maxLevel)
if (crystalCapacity < hours * crystalProduction && GetNextLevel(planet, Buildables.CrystalStorage) <= maxLevel)
return true;
else
return false;
Expand All @@ -2993,9 +2993,9 @@ public bool ShouldBuildCrystalStorage(Planet planet, int maxLevel, int speedFact
public bool ShouldBuildDeuteriumTank(Planet planet, int maxLevel, int speedFactor, int hours = 12, float ratio = 1, Researches researches = null, CharacterClass playerClass = CharacterClass.NoClass, bool hasGeologist = false, bool hasStaff = false, bool forceIfFull = false) {
long deuteriumProduction = CalcDeuteriumProduction(planet, speedFactor, ratio, researches, playerClass, hasGeologist, hasStaff);
long deuteriumCapacity = CalcDepositCapacity(planet.Buildings.DeuteriumTank);
if (forceIfFull && planet.Resources.Deuterium >= deuteriumCapacity && GetNextLevel(planet, Buildables.DeuteriumTank) < maxLevel)
if (forceIfFull && planet.Resources.Deuterium >= deuteriumCapacity && GetNextLevel(planet, Buildables.DeuteriumTank) <= maxLevel)
return true;
if (deuteriumCapacity < hours * deuteriumProduction && GetNextLevel(planet, Buildables.DeuteriumTank) < maxLevel)
if (deuteriumCapacity < hours * deuteriumProduction && GetNextLevel(planet, Buildables.DeuteriumTank) <= maxLevel)
return true;
else
return false;
Expand Down

0 comments on commit e271611

Please sign in to comment.