private int GetBoostableStatPoints(BoostableStat stat) { switch (stat) { case BoostableStat.Agility: return(Stats.Agility.Base); case BoostableStat.Strength: return(Stats.Strength.Base); case BoostableStat.Intelligence: return(Stats.Intelligence.Base); case BoostableStat.Chance: return(Stats.Chance.Base); case BoostableStat.Wisdom: return(Stats.Wisdom.Base); case BoostableStat.Vitality: return(Stats.Vitality.Base); default: throw new ArgumentException("stat"); } }
public BoostThreshold[] GetThresholds(BoostableStat stat) { switch (stat) { case BoostableStat.Agility: return(AgilityThreshold); case BoostableStat.Strength: return(StrengthThreshold); case BoostableStat.Intelligence: return(IntelligenceThreshold); case BoostableStat.Chance: return(ChanceThreshold); case BoostableStat.Wisdom: return(WisdomThreshold); case BoostableStat.Vitality: return(VitalityThreshold); default: throw new ArgumentException("stat"); } }
public void SpendStatsPoints(BoostableStat stat, short amount) { if (amount > Stats.SpellsPoints) { amount = (short)Stats.SpellsPoints; } Bot.SendToServer(new StatsUpgradeRequestMessage((sbyte)stat, amount)); }
/// <summary> /// Gives the amount of boost of a given stat with the given points /// </summary> /// <param name="stat"></param> /// <param name="pointsToSpend"></param> /// <returns></returns> public int GetBoostAmountWithPoints(BoostableStat stat, int pointsToSpend) { var currentPoints = GetBoostableStatPoints(stat); var threshold = Breed.GetThreshold(currentPoints, stat); var nextThreshold = Breed.GetNextThreshold(currentPoints, stat); if (pointsToSpend < threshold.PointsPerBoost) { return(0); } int totalBoost = 0; while (pointsToSpend >= threshold.PointsPerBoost) { int boost = 0; if (nextThreshold != null && currentPoints >= nextThreshold.PointsThreshold) { threshold = Breed.GetThreshold(currentPoints, stat); nextThreshold = Breed.GetNextThreshold(currentPoints, stat); } if (pointsToSpend - threshold.PointsPerBoost < 0) { break; } if (nextThreshold != null && (pointsToSpend / (double)threshold.PointsPerBoost) > (nextThreshold.PointsThreshold - currentPoints)) { boost = (short)(threshold.PointsThreshold - pointsToSpend); pointsToSpend -= (short)(boost * threshold.PointsPerBoost); boost = (short)(boost * threshold.BoostPerPoints); } else { boost = (short)Math.Floor(pointsToSpend / (double)threshold.PointsPerBoost); pointsToSpend -= (short)(boost * threshold.PointsPerBoost); boost = (short)(boost * threshold.BoostPerPoints); } currentPoints += boost; totalBoost += boost; } return(totalBoost); }
public short GetPointsForBoostAmount(BoostableStat stat, short amount) { var currentPoints = GetBoostableStatPoints(stat); var threshold = Breed.GetThreshold(currentPoints, stat); var nextThreshold = Breed.GetNextThreshold(currentPoints, stat); short pointsToSpend = 0; int totalBoost = 0; while (totalBoost < amount) { short boost = 0; if (nextThreshold != null && currentPoints >= nextThreshold.PointsThreshold) { threshold = Breed.GetThreshold(currentPoints, stat); nextThreshold = Breed.GetNextThreshold(currentPoints, stat); } // must fill the current threshold first if (nextThreshold != null && amount > (nextThreshold.PointsThreshold - currentPoints)) { boost = (short)(nextThreshold.PointsThreshold - pointsToSpend); pointsToSpend += (short)(boost * threshold.PointsPerBoost); boost = (short)(boost * threshold.BoostPerPoints); } else { pointsToSpend += (short)(amount * threshold.PointsPerBoost); boost = (short)(amount * threshold.BoostPerPoints); } amount -= boost; currentPoints += boost; totalBoost += boost; } return(pointsToSpend); }
private int GetBoostableStatPoints(BoostableStat stat) { switch (stat) { case BoostableStat.Agility: return Stats.Agility.Base; case BoostableStat.Strength: return Stats.Strength.Base; case BoostableStat.Intelligence: return Stats.Intelligence.Base; case BoostableStat.Chance: return Stats.Chance.Base; case BoostableStat.Wisdom: return Stats.Wisdom.Base; case BoostableStat.Vitality: return Stats.Vitality.Base; default: throw new ArgumentException("stat"); } }
/// <summary> /// Gives the amount of boost of a given stat with the given points /// </summary> /// <param name="stat"></param> /// <param name="pointsToSpend"></param> /// <returns></returns> public int GetBoostAmountWithPoints(BoostableStat stat, int pointsToSpend) { var currentPoints = GetBoostableStatPoints(stat); var threshold = Breed.GetThreshold(currentPoints, stat); var nextThreshold = Breed.GetNextThreshold(currentPoints, stat); if (pointsToSpend < threshold.PointsPerBoost) return 0; int totalBoost = 0; while (pointsToSpend >= threshold.PointsPerBoost) { int boost = 0; if (nextThreshold != null && currentPoints >= nextThreshold.PointsThreshold) { threshold = Breed.GetThreshold(currentPoints, stat); nextThreshold = Breed.GetNextThreshold(currentPoints, stat); } if (pointsToSpend - threshold.PointsPerBoost < 0) break; if (nextThreshold != null && (pointsToSpend / (double)threshold.PointsPerBoost) > (nextThreshold.PointsThreshold - currentPoints)) { boost = (short)(threshold.PointsThreshold - pointsToSpend); pointsToSpend -= (short)(boost * threshold.PointsPerBoost); boost = (short)(boost * threshold.BoostPerPoints); } else { boost = (short)Math.Floor(pointsToSpend / (double)threshold.PointsPerBoost); pointsToSpend -= (short)(boost * threshold.PointsPerBoost); boost = (short)(boost * threshold.BoostPerPoints); } currentPoints += boost; totalBoost += boost; } return totalBoost; }
public short GetPointsForBoostAmount(BoostableStat stat, short amount) { var currentPoints = GetBoostableStatPoints(stat); var threshold = Breed.GetThreshold(currentPoints, stat); var nextThreshold = Breed.GetNextThreshold(currentPoints, stat); short pointsToSpend = 0; int totalBoost = 0; while (totalBoost < amount) { short boost = 0; if (nextThreshold != null && currentPoints >= nextThreshold.PointsThreshold) { threshold = Breed.GetThreshold(currentPoints, stat); nextThreshold = Breed.GetNextThreshold(currentPoints, stat); } // must fill the current threshold first if (nextThreshold != null && amount > (nextThreshold.PointsThreshold - currentPoints)) { boost = (short)(nextThreshold.PointsThreshold - pointsToSpend); pointsToSpend += (short)(boost * threshold.PointsPerBoost); boost = (short)(boost * threshold.BoostPerPoints); } else { pointsToSpend += (short)(amount * threshold.PointsPerBoost); boost = (short)(amount * threshold.BoostPerPoints); } amount -= boost; currentPoints += boost; totalBoost += boost; } return pointsToSpend; }
public void SpendStatsPoints(BoostableStat stat, short amount) { if (amount > Stats.SpellsPoints) amount = (short)Stats.SpellsPoints; Bot.SendToServer(new StatsUpgradeRequestMessage((sbyte)stat, amount)); }
/// <summary> /// Gives the next threshold or null if not found /// </summary> /// <param name="actualpoints"></param> /// <param name="stat"> </param> /// <returns></returns> public BoostThreshold GetNextThreshold(int actualpoints, BoostableStat stat) { return(GetNextThreshold(actualpoints, GetThresholds(stat))); }
/// <summary> /// Gives the next threshold or null if not found /// </summary> /// <param name="actualpoints"></param> /// <param name="stat"> </param> /// <returns></returns> public BoostThreshold GetNextThreshold(int actualpoints, BoostableStat stat) { return GetNextThreshold(actualpoints, GetThresholds(stat)); }
public BoostThreshold[] GetThresholds(BoostableStat stat) { switch (stat) { case BoostableStat.Agility: return AgilityThreshold; case BoostableStat.Strength: return StrengthThreshold; case BoostableStat.Intelligence: return IntelligenceThreshold; case BoostableStat.Chance: return ChanceThreshold; case BoostableStat.Wisdom: return WisdomThreshold; case BoostableStat.Vitality: return VitalityThreshold; default: throw new ArgumentException("stat"); } }