| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- public sealed class Stats : IEquatable<Stats>
- {
- public SortedDictionary<Stat, int> Values { get; set; } = new SortedDictionary<Stat, int>();
- public int Count => Values.Sum(pair => Math.Abs(pair.Value));
- public int this[Stat stat]
- {
- get
- {
- return !Values.TryGetValue(stat, out int result) ? 0 : result;
- }
- set
- {
- if (value == 0)
- {
- if (Values.ContainsKey(stat))
- {
- Values.Remove(stat);
- }
- return;
- }
- Values[stat] = value;
- }
- }
- public Stats() { }
- public Stats(Stats stats)
- {
- foreach (KeyValuePair<Stat, int> pair in stats.Values)
- this[pair.Key] += pair.Value;
- }
- public Stats(BinaryReader reader, int version = int.MaxValue, int customVersion = int.MaxValue)
- {
- int count = reader.ReadInt32();
- for (int i = 0; i < count; i++)
- Values[(Stat)reader.ReadByte()] = reader.ReadInt32();
- }
- public void Add(Stats stats)
- {
- foreach (KeyValuePair<Stat, int> pair in stats.Values)
- this[pair.Key] += pair.Value;
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(Values.Count);
- foreach (KeyValuePair<Stat, int> pair in Values)
- {
- writer.Write((byte)pair.Key);
- writer.Write(pair.Value);
- }
- }
- public void Clear()
- {
- Values.Clear();
- }
- public bool Equals(Stats other)
- {
- if (Values.Count != other.Values.Count) return false;
- foreach (KeyValuePair<Stat, int> value in Values)
- if (other[value.Key] != value.Value) return false;
- return true;
- }
- }
- public enum StatFormula : byte
- {
- Health,
- Mana,
- Weight,
- Stat
- }
- public enum Stat : byte
- {
- MinAC = 0,
- MaxAC = 1,
- MinMAC = 2,
- MaxMAC = 3,
- MinDC = 4,
- MaxDC = 5,
- MinMC = 6,
- MaxMC = 7,
- MinSC = 8,
- MaxSC = 9,
- Accuracy = 10,
- Agility = 11,
- HP = 12,
- MP = 13,
- AttackSpeed = 14,
- Luck = 15,
- BagWeight = 16,
- HandWeight = 17,
- WearWeight = 18,
- Reflect = 19,
- Strong = 20,
- Holy = 21,
- Freezing = 22,
- PoisonAttack = 23,
- MagicResist = 30,
- PoisonResist = 31,
- HealthRecovery = 32,
- SpellRecovery = 33,
- PoisonRecovery = 34, //TODO - Should this be in seconds or milliseconds??
- CriticalRate = 35,
- CriticalDamage = 36,
- MaxACRatePercent = 40,
- MaxMACRatePercent = 41,
- MaxDCRatePercent = 42,
- MaxMCRatePercent = 43,
- MaxSCRatePercent = 44,
- AttackSpeedRatePercent = 45,
- HPRatePercent = 46,
- MPRatePercent = 47,
- HPDrainRatePercent = 48,
- ExpRatePercent = 100,
- ItemDropRatePercent = 101,
- GoldDropRatePercent = 102,
- MineRatePercent = 103,
- GemRatePercent = 104,
- FishRatePercent = 105,
- CraftRatePercent = 106,
- SkillGainMultiplier = 107,
- AttackBonus = 108,
- LoverExpRatePercent = 120,
- MentorDamageRatePercent = 121,
- MentorExpRatePercent = 123,
- DamageReductionPercent = 124,
- EnergyShieldPercent = 125,
- EnergyShieldHPGain = 126,
- ManaPenaltyPercent = 127,
- TeleportManaPenaltyPercent = 128,
- Hero = 129,
- Unknown = 255
- }
|