Make this into multiple different functions for use with other stuff
This commit is contained in:
@@ -78,20 +78,36 @@ public static class Tools
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (BigInteger totalXp, double level, BigInteger currentXpInLevel, BigInteger totalXpForLevel, double percentDone) GetLevelInfo()
|
public static BigInteger CalculateXP(BigInteger normalBerries, BigInteger poisonBerries, BigInteger slowBerries, BigInteger ultraBerries, BigInteger speedyBerries, BigInteger coinBerries)
|
||||||
{
|
{
|
||||||
BigInteger totalXp = 0;
|
BigInteger totalXp = 0;
|
||||||
totalXp += BazookaManager.Instance.GetGameStoreTotalNormalBerries();
|
totalXp += normalBerries;
|
||||||
totalXp -= BazookaManager.Instance.GetGameStoreTotalPoisonBerries();
|
totalXp -= poisonBerries;
|
||||||
totalXp -= BazookaManager.Instance.GetGameStoreTotalSlowBerries();
|
totalXp -= slowBerries;
|
||||||
totalXp += BazookaManager.Instance.GetGameStoreTotalUltraBerries() * 5;
|
totalXp += ultraBerries * 5;
|
||||||
totalXp += BazookaManager.Instance.GetGameStoreTotalSpeedyBerries() * 10;
|
totalXp += speedyBerries * 10;
|
||||||
totalXp += BazookaManager.Instance.GetGameStoreTotalCoinBerries() * 10;
|
totalXp += coinBerries * 10;
|
||||||
if (totalXp < 0) totalXp = 0;
|
if (totalXp < 0) totalXp = 0;
|
||||||
|
return totalXp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BigInteger CalculateXP()
|
||||||
|
{
|
||||||
|
return CalculateXP(
|
||||||
|
BazookaManager.Instance.GetGameStoreTotalNormalBerries(),
|
||||||
|
BazookaManager.Instance.GetGameStoreTotalPoisonBerries(),
|
||||||
|
BazookaManager.Instance.GetGameStoreTotalSlowBerries(),
|
||||||
|
BazookaManager.Instance.GetGameStoreTotalUltraBerries(),
|
||||||
|
BazookaManager.Instance.GetGameStoreTotalSpeedyBerries(),
|
||||||
|
BazookaManager.Instance.GetGameStoreTotalCoinBerries()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (BigInteger totalXp, double level, BigInteger currentXpInLevel, BigInteger totalXpForLevel, double percentDone) GetLevelInfo(BigInteger xp)
|
||||||
|
{
|
||||||
double levelDivisor = 50.0;
|
double levelDivisor = 50.0;
|
||||||
|
|
||||||
double discriminant = 95 * 95 + levelDivisor * 2 * (double)totalXp;
|
double discriminant = 95 * 95 + levelDivisor * 2 * (double)xp;
|
||||||
double level = (-95 + Math.Sqrt(discriminant)) / levelDivisor;
|
double level = (-95 + Math.Sqrt(discriminant)) / levelDivisor;
|
||||||
double flooredLevel = Math.Floor(level);
|
double flooredLevel = Math.Floor(level);
|
||||||
|
|
||||||
@@ -101,11 +117,17 @@ public static class Tools
|
|||||||
BigInteger xpAtNextLevel = (BigInteger)(levelDivisor / 2 * nextLevel * nextLevel + 95 * nextLevel);
|
BigInteger xpAtNextLevel = (BigInteger)(levelDivisor / 2 * nextLevel * nextLevel + 95 * nextLevel);
|
||||||
|
|
||||||
BigInteger totalXpForLevel = xpAtNextLevel - xpAtStartOfLevel;
|
BigInteger totalXpForLevel = xpAtNextLevel - xpAtStartOfLevel;
|
||||||
BigInteger currentXpInLevel = totalXp - xpAtStartOfLevel;
|
BigInteger currentXpInLevel = xp - xpAtStartOfLevel;
|
||||||
|
|
||||||
double percentDone = totalXpForLevel == 0 ? 0.0 : (double)currentXpInLevel / (double)totalXpForLevel * 100.0;
|
double percentDone = totalXpForLevel == 0 ? 0.0 : (double)currentXpInLevel / (double)totalXpForLevel * 100.0;
|
||||||
|
|
||||||
return (totalXp, flooredLevel + 1, currentXpInLevel, totalXpForLevel, percentDone);
|
return (xp, flooredLevel + 1, currentXpInLevel, totalXpForLevel, percentDone);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (BigInteger totalXp, double level, BigInteger currentXpInLevel, BigInteger totalXpForLevel, double percentDone) GetLevelInfo()
|
||||||
|
{
|
||||||
|
var (totalXp, level, currentXpInLevel, totalXpForLevel, percentDone) = GetLevelInfo(CalculateXP());
|
||||||
|
return (totalXp, level, currentXpInLevel, totalXpForLevel, percentDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatHumanTime(long unixTimestamp)
|
public static string FormatHumanTime(long unixTimestamp)
|
||||||
|
|||||||
Reference in New Issue
Block a user