/// <summary> /// Deserialization constructor from datafiles. /// </summary> /// <param name="group"></param> /// <param name="src"></param> /// <param name="arrayIndex"></param> internal StaticSkill(StaticSkillGroup group, SerializableSkill src, int arrayIndex) { m_id = src.ID; m_cost = src.Cost; m_rank = src.Rank; m_public = src.Public; m_name = src.Name; m_description = src.Description; m_descriptionNL = null; m_primaryAttribute = src.PrimaryAttribute; m_secondaryAttribute = src.SecondaryAttribute; m_trainableOnTrialAccount = src.CanTrainOnTrial; m_arrayIndex = arrayIndex; m_group = group; }
/// <summary> /// Deserialization constructor from datafiles. /// </summary> /// <param name="group"></param> /// <param name="src"></param> /// <param name="arrayIndex"></param> internal StaticSkill(StaticSkillGroup group, SerializableSkill src, int arrayIndex) { ID = src.ID; Cost = src.Cost; Rank = src.Rank; IsPublic = src.Public; Name = src.Name; Description = src.Description; PrimaryAttribute = src.PrimaryAttribute; SecondaryAttribute = src.SecondaryAttribute; IsTrainableOnTrialAccount = src.CanTrainOnTrial; ArrayIndex = arrayIndex; Group = group; Prerequisites = new Collection<StaticSkillLevel>(); FormattedCost = Cost.ToNumericString(0); }
/// <summary> /// Generate the skills datafile. /// </summary> private static void GenerateSkills() { Console.WriteLine(); Console.Write(@"Generated skills datafile... "); s_counter = 0; s_percentOld = 0; s_text = String.Empty; s_startTime = DateTime.Now; // Export skill groups var listOfSkillGroups = new List<SerializableSkillGroup>(); foreach (InvGroup group in s_groups.Where(x => x.CategoryID == 16 && x.ID != 505).OrderBy(x => x.Name)) { var skillGroup = new SerializableSkillGroup { ID = group.ID, Name = group.Name, }; // Export skills var listOfSkillsInGroup = new List<SerializableSkill>(); foreach (InvType skill in s_types.Where(x => x.GroupID == group.ID)) { UpdatePercentDone(s_skillGenTotal); var singleSkill = new SerializableSkill { ID = skill.ID, Name = skill.Name, Description = skill.Description, Public = skill.Published, Cost = (long) skill.BasePrice, }; // Export skill atributes var skillAttributes = new Dictionary<int, int>(); foreach (DgmTypeAttribute attribute in s_typeAttributes.Where(x => x.ItemID == skill.ID)) { skillAttributes.Add(attribute.AttributeID, attribute.GetIntValue()); } if (skillAttributes.ContainsKey(275) && skillAttributes[275] > 0) { singleSkill.Rank = skillAttributes[275]; } else { singleSkill.Rank = 1; } singleSkill.PrimaryAttribute = skillAttributes.ContainsKey(180) ? IntToEveAttribute(skillAttributes[180]) : EveAttribute.None; singleSkill.SecondaryAttribute = skillAttributes.ContainsKey(181) ? IntToEveAttribute(skillAttributes[181]) : EveAttribute.None; singleSkill.CanTrainOnTrial = skillAttributes.ContainsKey(1047) && skillAttributes[1047] == 0 ? true : false; // Export prerequesities var listOfPrerequisites = new List<SerializableSkillPrerequisite>(); for (int i = 0; i < DBConstants.RequiredSkillPropertyIDs.Length; i++) { if (skillAttributes.ContainsKey(DBConstants.RequiredSkillPropertyIDs[i]) && skillAttributes.ContainsKey(DBConstants.RequiredSkillLevelPropertyIDs[i])) { var j = i; InvType prereqSkill = s_types.First(x => x.ID == skillAttributes[DBConstants.RequiredSkillPropertyIDs[j]]); var preReq = new SerializableSkillPrerequisite { ID = prereqSkill.ID, Level = skillAttributes[DBConstants.RequiredSkillLevelPropertyIDs[i]], }; if (prereqSkill != null) preReq.Name = prereqSkill.Name; // Add prerequisites listOfPrerequisites.Add(preReq); } } // Add prerequesites to skill singleSkill.Prereqs = listOfPrerequisites.ToArray(); // Add skill listOfSkillsInGroup.Add(singleSkill); } // Add skills in skill group skillGroup.Skills = listOfSkillsInGroup.OrderBy(x => x.Name).ToArray(); // Add skill group listOfSkillGroups.Add(skillGroup); } s_endTime = DateTime.Now; Console.WriteLine(String.Format(" in {0}", s_endTime.Subtract(s_startTime)).TrimEnd('0')); // Serialize var datafile = new SkillsDatafile(); datafile.Groups = listOfSkillGroups.ToArray(); Util.SerializeXML(datafile, DatafileConstants.SkillsDatafile); }
/// <summary> /// Exports the skills in the skill group. /// </summary> /// <param name="group">The group.</param> /// <returns></returns> private static IEnumerable<SerializableSkill> ExportSkillsInGroup(IHasID group) { List<SerializableSkill> listOfSkillsInGroup = new List<SerializableSkill>(); foreach (InvTypes skill in Database.InvTypesTable.Where(x => x.GroupID == group.ID)) { Util.UpdatePercentDone(Database.SkillsTotalCount); SerializableSkill singleSkill = new SerializableSkill { ID = skill.ID, Name = skill.Name, Description = skill.Description, Public = skill.Published, Cost = (long)skill.BasePrice, }; // Export skill atributes Dictionary<int, Int64> skillAttributes = Database.DgmTypeAttributesTable.Where( x => x.ItemID == skill.ID).ToDictionary( attribute => attribute.AttributeID, attribute => attribute.GetInt64Value); singleSkill.Rank = skillAttributes.ContainsKey(DBConstants.SkillTimeConstantPropertyID) && skillAttributes[DBConstants.SkillTimeConstantPropertyID] > 0 ? skillAttributes[DBConstants.SkillTimeConstantPropertyID] : 1; singleSkill.PrimaryAttribute = skillAttributes.ContainsKey(DBConstants.PrimaryAttributePropertyID) ? IntToEveAttribute(skillAttributes[DBConstants.PrimaryAttributePropertyID]) : EveAttribute.None; singleSkill.SecondaryAttribute = skillAttributes.ContainsKey(DBConstants.SecondaryAttributePropertyID) ? IntToEveAttribute( skillAttributes[DBConstants.SecondaryAttributePropertyID]) : EveAttribute.None; singleSkill.CanTrainOnTrial = !skillAttributes.ContainsKey(DBConstants.CanNotBeTrainedOnTrialPropertyID) || skillAttributes[DBConstants.CanNotBeTrainedOnTrialPropertyID] == 0; // Export prerequesities List<SerializableSkillPrerequisite> listOfPrerequisites = new List<SerializableSkillPrerequisite>(); for (int i = 0; i < DBConstants.RequiredSkillPropertyIDs.Count; i++) { if (!skillAttributes.ContainsKey(DBConstants.RequiredSkillPropertyIDs[i]) || !skillAttributes.ContainsKey(DBConstants.RequiredSkillLevelPropertyIDs[i])) continue; InvTypes prereqSkill = Database.InvTypesTable[skillAttributes[DBConstants.RequiredSkillPropertyIDs[i]]]; SerializableSkillPrerequisite preReq = new SerializableSkillPrerequisite { ID = prereqSkill.ID, Level = skillAttributes[DBConstants.RequiredSkillLevelPropertyIDs[i]], Name = prereqSkill.Name }; // Add prerequisites listOfPrerequisites.Add(preReq); } // Add prerequesites to skill singleSkill.SkillPrerequisites.AddRange(listOfPrerequisites); // Add skill listOfSkillsInGroup.Add(singleSkill); } return listOfSkillsInGroup; }