Пример #1
0
        public int CompareTo(Mastery other)
        {
            MasteryShip sm = MasteryShip, osm = other.MasteryShip;
            int         comparison;

            if (sm == null)
            {
                // NULL versions should not be intermixed, but if they are, put them last
                comparison = (osm == null) ? 0 : 1;
            }
            else if (osm == null)
            {
                comparison = -1;
            }
            else
            {
                // Both are not null
                string shipOne = sm.Ship?.Name ?? string.Empty, shipTwo = osm.Ship?.Name ??
                                                                          string.Empty;
                comparison = shipOne.CompareTo(shipTwo);
                if (comparison == 0)
                {
                    // Levels are 1 to 5, no overflow can occur here
                    comparison = Level - other.Level;
                }
            }
            return(comparison);
        }
Пример #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));
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MasteryShip"/> class.
        /// </summary>
        /// <param name="character">The character.</param>
        /// <param name="masteryShip">The mastery ship.</param>
        internal MasteryShip(Character character, MasteryShip masteryShip) : base(masteryShip.
                                                                                  Count)
        {
            Character = character;
            Ship      = masteryShip.Ship;
            // Add in sorted order 1-5
            var masteriesSorted = new List <Mastery>(masteryShip.Count);

            foreach (var mastery in masteryShip)
            {
                masteriesSorted.Add(new Mastery(character, mastery));
            }
            masteriesSorted.Sort();
            Items.AddRange(masteriesSorted);
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MasteryShip"/> class.
        /// </summary>
        /// <param name="character">The character.</param>
        /// <param name="masteryShip">The mastery ship.</param>
        internal MasteryShip(Character character, MasteryShip masteryShip)
            : base(masteryShip?.Count ?? 0)
        {
            if (masteryShip == null)
            {
                return;
            }

            Character = character;
            Ship      = masteryShip.Ship;

            foreach (Mastery mastery in masteryShip)
            {
                Items.Add(new Mastery(character, mastery));
            }
        }