示例#1
0
        /// <summary>
        /// Exports the masteries.
        /// </summary>
        /// <param name="typeMasteries">The type masteries.</param>
        /// <returns></returns>
        private static IEnumerable <SerializableMastery> ExportMasteries(IGrouping <int, DgmTypeMasteries> typeMasteries)
        {
            List <SerializableMastery> listOfMasteries = new List <SerializableMastery>();

            foreach (DgmMasteries typeMastery in typeMasteries.Select(x => Database.DgmMasteriesTable[x.MasteryID]))
            {
                Util.UpdatePercentDone(Database.MasteriesTotalCount);

                int grade = typeMastery.Grade + 1;

                SerializableMastery mastery;
                if (listOfMasteries.All(x => x.Grade != grade))
                {
                    mastery = new SerializableMastery {
                        Grade = grade
                    };
                    listOfMasteries.Add(mastery);
                }
                else
                {
                    mastery = listOfMasteries.First(x => x.Grade == grade);
                }

                SerializableMasteryCertificate masteryCertificate = new SerializableMasteryCertificate
                {
                    ID        = typeMastery.CertificateID,
                    ClassName =
                        Database.CrtClassesTable[Database.CrtCertificatesTable[typeMastery.CertificateID].ClassID].ClassName
                };

                mastery.Certificates.Add(masteryCertificate);
            }

            return(listOfMasteries);
        }
示例#2
0
 /// <summary>
 /// Deserialization constructor.
 /// </summary>
 /// <param name="masteryShip">The mastery ship.</param>
 /// <param name="src">The source.</param>
 internal Mastery(MasteryShip masteryShip, SerializableMastery src)
     : base(src?.Certificates.Count ?? 0)
 {
     if (src != null)
     {
         MasteryShip = masteryShip;
         Level       = src.Grade;
         Status      = MasteryStatus.Untrained;
         foreach (SerializableMasteryCertificate certificate in src.Certificates)
         {
             Items.Add(new MasteryCertificate(this, certificate));
         }
     }
 }