namespace ODMO.Commons.Models.Digimon { public sealed partial class DigimonEvolutionModel { /// /// Increases the current skill experience. /// Amount to increase /// public void IncreaseSkillExperience(int value) => SkillExperience += value; /// /// Restart the current skill experience. /// Amount to increase /// public void RestartSkillExperience(int value) => SkillExperience = value; /// /// Unlocks the target evolution. /// public void Unlock(byte value = 1) => Unlocked = value; /// /// Unlocks the target evolution ride mode. /// public void UnlockRide() => Unlocked += 8; /// /// Increases the skill points amount. /// /// Points to increase public void IncreaseSkillPoints(byte points = 2) { SkillPoints += points; SkillMastery++; } /// /// Decrease the skill points amount. /// /// Points to increase public void DecreaseSkillPoints(byte points) { SkillPoints -= points; } /// /// Inserts new skills into the list. /// /// The amount to add public void AddSkill(int amount = 1) { for (int i = 0; i < amount; i++) Skills.Add(new DigimonEvolutionSkillModel()); } public void SetId(long id) { Id = id; } /// /// Serializes the object into byte array. /// public byte[] ToArray() { using MemoryStream m = new(); m.Write(BitConverter.GetBytes(GetSkillExpValue(SkillExperience, SkillMastery)), 0, 4); m.WriteByte(Unlocked); m.WriteByte(0); m.WriteByte(0); m.WriteByte(0); m.WriteByte(SkillPoints); foreach (var skill in Skills) m.WriteByte(skill.CurrentLevel); foreach (var skill in Skills) m.WriteByte(skill.MaxLevel); return m.ToArray(); } public int GetSkillExpValue(int skillExp, int skillLevel) { // Calcula o valor inteiro correspondente ao nível int m_nSkillExpLevel = skillLevel; // Calcula o valor inteiro correspondente à experiência int m_nSkillExp = skillExp; // Combina os valores para formar o valor inteiro final int value = (m_nSkillExpLevel << 26) | m_nSkillExp; return value; } } }