Exemplo n.º 1
0
        /// <summary>
        /// Completes the initialization by updating the prequisites and checking trainability on trial account
        /// </summary>
        internal void CompleteInitialization(SerializableSkillPrerequisite[] prereqs)
        {
            if (prereqs == null)
                return;

            // Create the prerequisites list
            m_prereqs.AddRange(prereqs.Select(x => new StaticSkillLevel(x.GetSkill(), x.Level)));

            // Check trainableOnTrialAccount on its childrens to be sure it's really trainable
            if (m_trainableOnTrialAccount)
            {
                foreach (var prereq in m_prereqs)
                {
                    if (!prereq.Skill.m_trainableOnTrialAccount)
                    {
                        m_trainableOnTrialAccount = false;
                        return;
                    }
                }
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <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;
        }