public uint[][] GetThresholds(StatsBoostEnum statsid) { uint[][] result = null; switch (statsid) { case StatsBoostEnum.Strength: result = this.SPForStrength.Values; break; case StatsBoostEnum.Vitality: result = this.SPForVitality.Values; break; case StatsBoostEnum.Wisdom: result = this.SPForWisdom.Values; break; case StatsBoostEnum.Chance: result = this.SPForChance.Values; break; case StatsBoostEnum.Agility: result = this.SPForAgility.Values; break; case StatsBoostEnum.Intelligence: result = this.SPForIntelligence.Values; break; } return(result); }
public Characteristic GetCharacteristic(StatsBoostEnum statId) { var proprety = this.GetType().GetProperty(statId.ToString()); return(proprety != null ? (Characteristic)proprety.GetValue(this) : null); }
public static void HandleStatUpgrade(StatsUpgradeRequestMessage message, WorldClient client) { if (!client.Character.Fighting) { StatsBoostEnum statId = (StatsBoostEnum)message.statId; var characteristic = client.Character.Record.Stats.GetCharacteristic(statId); if (characteristic == null) { client.Character.ReplyError("Wrong StatId."); client.Send(new StatsUpgradeResultMessage((sbyte)StatsUpgradeResultEnum.NONE, message.boostPoint)); return; } if (message.boostPoint > 0) { int num = characteristic.Base; ushort num2 = message.boostPoint; if (num2 >= 1 && message.boostPoint <= (short)client.Character.Record.StatsPoints) { uint[][] thresholds = client.Character.Breed.GetThresholds(statId); int thresholdIndex = client.Character.Breed.GetThresholdIndex(num, thresholds); while (num2 >= (long)thresholds[thresholdIndex][1]) { short num3; short num4; if (thresholdIndex < thresholds.Length - 1 && (double)num2 / thresholds[thresholdIndex][1] > thresholds[thresholdIndex + 1][0] - (ulong)num) { num3 = (short)(thresholds[thresholdIndex + 1][0] - (ulong)num); num4 = (short)(num3 * thresholds[thresholdIndex][1]); if (thresholds[thresholdIndex].Length > 2) { num3 = (short)(num3 * thresholds[thresholdIndex][2]); } } else { num3 = (short)Math.Floor((double)num2 / thresholds[thresholdIndex][1]); num4 = (short)(num3 * thresholds[thresholdIndex][1]); if (thresholds[thresholdIndex].Length > 2) { num3 = (short)(num3 * thresholds[thresholdIndex][2]); } } num += num3; num2 -= (ushort)num4; thresholdIndex = client.Character.Breed.GetThresholdIndex(num, thresholds); } if (statId == StatsBoostEnum.Vitality) { int num5 = num - characteristic.Base; client.Character.Record.Stats.LifePoints += num5; client.Character.Record.Stats.MaxLifePoints += num5; } characteristic.Base = (short)num; client.Character.Record.StatsPoints -= (ushort)(message.boostPoint - num2); client.Send(new StatsUpgradeResultMessage((sbyte)StatsUpgradeResultEnum.SUCCESS, message.boostPoint)); client.Character.RefreshStats(); } else { client.Send(new StatsUpgradeResultMessage((sbyte)StatsUpgradeResultEnum.NOT_ENOUGH_POINT, message.boostPoint)); } } } else { client.Send(new StatsUpgradeResultMessage((sbyte)StatsUpgradeResultEnum.IN_FIGHT, 0)); } }
public uint[] GetThreshold(short actualpoints, StatsBoostEnum statsid) { uint[][] thresholds = this.GetThresholds(statsid); return(thresholds[this.GetThresholdIndex((int)actualpoints, thresholds)]); }