Add Population Target and more deriveds

This commit is contained in:
2024-09-25 19:01:49 +02:00
parent efa5d452ea
commit cafa45bed3
4 changed files with 47 additions and 13 deletions

View File

@ -40,7 +40,7 @@ public class GameEngine
public static int PlanetPopGrowthForPlayer(int currentPop, int value)
{
int maxPop = MaxPopOnPlanetForPlayer(value);
double growth;
int growth;
if (value < 0)
{
@ -49,16 +49,30 @@ public class GameEngine
else
{
double popRatio = (double) currentPop / maxPop;
if (popRatio <= 0.25)
growth = currentPop * value / 100.0 * Game.Player.GrowthRatePercent / 100.0;
else if (popRatio <= 1)
growth = currentPop * value / 100.0 * Game.Player.GrowthRatePercent / 100.0 * 16.0 / 9.0 * Math.Pow(1.0 - popRatio, 2);
else
growth = currentPop * (popRatio - 1) * 0.04;
if (popRatio <= 0.25)
{
growth = currentPop
* Game.Player.GrowthRatePercent / 100
* value / 100;
}
else if (popRatio < 1)
{
double factor = Math.Pow(1.0 - popRatio, 2);
growth = currentPop
* Game.Player.GrowthRatePercent / 100
* value / 100
* 16 / 9;
growth = (int) ((double) growth * factor);
}
else
{
double factor = 0.04 * (popRatio - 1);
growth = (int) ((double) currentPop * factor);
}
}
// round to nearest 100
return ((int) growth) / 100 * 100;
// round down by 100
return growth / 100 * 100;
}
/// <summary>