namespace ODMO.Commons.Models.Character { public sealed partial class CharacterProgressModel { /// /// Serializes the progress object. /// public byte[] ToArray() { byte[] buffer = Array.Empty(); using (MemoryStream m = new(1248)) { Buffer.BlockCopy(CompletedDataValue, 0, CompletedData, 0, CompletedData.Length); //var temp = new byte[340]; //m.Write(temp.ToArray(), 0, 340); m.Write(CompletedData.ToArray(), 0, 768); foreach (var inProgressQuest in InProgressQuestData) m.Write(inProgressQuest.ToArray(), 0, 7); var remaningQuestsToAdd = 20 - InProgressQuestData.Count; for (int i = 0; i < remaningQuestsToAdd; i++) m.Write(new InProgressQuestModel().ToArray(), 0, 7); buffer = m.ToArray(); } return buffer; } /// /// Adds a new quest to the current quests list. /// /// Quest identifier /// True when the tamer has free quest slots to add this quest. public bool AcceptQuest(short questId) { if (InProgressQuestData.Count >= 20) return false; InProgressQuestData.Add(new InProgressQuestModel(questId)); return true; } /// /// Removes the quest from the current quests list. /// /// Quest identifier public Guid? RemoveQuest(short questId) { var progress = InProgressQuestData.FirstOrDefault(x => x.QuestId == questId); InProgressQuestData.RemoveAll(x => x.QuestId == questId); return progress?.Id; } /// /// Updates quest progress? /// public void UpdateQuestInProgress(short questId, int goalIndex, byte value) { InProgressQuestData.FirstOrDefault(x => x.QuestId == questId)?.UpdateCondition(goalIndex, value); } public byte GetQuestGoalProgress(short questId, int goalIndex) { return InProgressQuestData.First(x => x.QuestId == questId).GetGoalValue(goalIndex); } } }