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); }
/// <summary> /// Initializes a new instance of the <see cref="Mastery"/> class. /// </summary> /// <param name="character">The character.</param> /// <param name="mastery">The mastery.</param> internal Mastery(Character character, Mastery mastery) : base(mastery.Count) { m_character = character; MasteryShip = mastery.MasteryShip; Level = mastery.Level; Status = MasteryStatus.Untrained; foreach (MasteryCertificate masteryCertificate in mastery) { Items.Add(new MasteryCertificate(character, masteryCertificate)); } }
/// <summary> /// Deserialization constructor. /// </summary> /// <param name="masteryLevel">The mastery level.</param> /// <param name="src">The source.</param> internal MasteryCertificate(Mastery masteryLevel, SerializableMasteryCertificate src) { MasteryLevel = masteryLevel; Certificate = StaticCertificates.GetCertificateByID(src.ID); }