public static void HandleStatsUpgrade(StatsUpgradeRequestMessage message, WorldClient client) { if (client.Character.IsFighting) { client.Send(new StatsUpgradeResultMessage((sbyte)StatsUpgradeResultEnum.IN_FIGHT, 0)); return; } StatsBoostTypeEnum statId = (StatsBoostTypeEnum)message.statId; if (statId < StatsBoostTypeEnum.Strength || statId > StatsBoostTypeEnum.Intelligence) { Logger.Error("Wrong statsid"); } if (message.boostPoint > 0) { UInt16ReflectedStat linkedStat = GetReflectedStat(client.Character.StatsRecord, statId); BreedRecord breed = BreedRecord.GetBreed(client.Character.Record.Breed); int num = linkedStat.GetValue(); ushort num2 = message.boostPoint; if (num2 >= 1 && message.boostPoint <= (short)client.Character.Record.StatsPoints) { uint[][] thresholds = breed.GetThresholds(statId); int thresholdIndex = breed.GetThresholdIndex(num, thresholds); while ((long)num2 >= (long)((ulong)thresholds[thresholdIndex][1])) { short num3; short num4; if (thresholdIndex < thresholds.Length - 1 && (double)num2 / thresholds[thresholdIndex][1] > (double)((ulong)thresholds[thresholdIndex + 1][0] - (ulong)((long)num))) { num3 = (short)((ulong)thresholds[thresholdIndex + 1][0] - (ulong)((long)num)); num4 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][1])); if (thresholds[thresholdIndex].Length > 2) { num3 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][2])); } } else { num3 = (short)System.Math.Floor((double)num2 / thresholds[thresholdIndex][1]); num4 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][1])); if (thresholds[thresholdIndex].Length > 2) { num3 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][2])); } } num += (int)num3; num2 -= (ushort)num4; thresholdIndex = breed.GetThresholdIndex(num, thresholds); } if (statId == StatsBoostTypeEnum.Vitality) { var previousVitality = linkedStat.GetValue(); linkedStat.SetValue((short)num); client.Character.StatsRecord.LifePoints += (short)(client.Character.StatsRecord.BaseVitality - previousVitality); client.Character.CurrentStats.LifePoints += (uint)(client.Character.StatsRecord.BaseVitality - previousVitality); } else { linkedStat.SetValue((short)num); } client.Character.Record.StatsPoints -= (ushort)(message.boostPoint - num2); client.Send(new StatsUpgradeResultMessage((sbyte)StatsUpgradeResultEnum.SUCCESS, message.boostPoint)); client.Character.RefreshStats(); } } }