Removes old comparable/comparers. (#31)

This commit is contained in:
Kamron Batman 2019-03-11 15:35:04 -07:00 • committed by GitHub
parent 513e54f70e
commit a45094f2dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 95 additions and 249 deletions

View file

@ -15,10 +15,10 @@ using Server.Targeting;
namespace Server.Factions
{
[CustomEnum(new[] { "Minax", "Council of Mages", "True Britannians", "Shadowlords" })]
public abstract class Faction : IComparable
public abstract class Faction : IComparable<Faction>
{
public const int StabilityFactor = 300; // 300% greater (3 times) than smallest faction
public const int StabilityActivation = 200; // Stablity code goes into effect when largest faction has > 200 people
public const int StabilityActivation = 200; // Stability code goes into effect when largest faction has > 200 people
public static readonly TimeSpan LeavePeriod = TimeSpan.FromDays(3.0);
@ -88,9 +88,9 @@ namespace Server.Factions
public static List<Faction> Factions => Reflector.Factions;
public int CompareTo(object obj)
public int CompareTo(Faction f)
{
return m_Definition.Sort - ((Faction)obj).m_Definition.Sort;
return m_Definition.Sort - (f?.m_Definition.Sort ?? 0);
}
public void Broadcast(string text)

View file

@ -4,7 +4,7 @@ using Server.Mobiles;
namespace Server.Factions
{
public class PlayerState : IComparable
public class PlayerState : IComparable<PlayerState>
{
private Town m_Finance;
@ -241,17 +241,14 @@ namespace Server.Factions
public bool IsActive{ get; set; }
public int CompareTo(object obj)
public int CompareTo(PlayerState ps)
{
return ((PlayerState)obj).m_KillPoints - m_KillPoints;
return (ps?.m_KillPoints ?? 0) - m_KillPoints;
}
public bool CanGiveSilverTo(Mobile mob)
{
if (SilverGiven == null)
return true;
for (int i = 0; i < SilverGiven.Count; ++i)
for (int i = 0; i < SilverGiven?.Count; ++i)
{
SilverGivenEntry sge = SilverGiven[i];
@ -307,4 +304,4 @@ namespace Server.Factions
return mob is PlayerMobile mobile ? mobile.FactionPlayerState : null;
}
}
}
}

View file

@ -6,7 +6,7 @@ using Server.Targeting;
namespace Server.Factions
{
[CustomEnum(new[] { "Britain", "Magincia", "Minoc", "Moonglow", "Skara Brae", "Trinsic", "Vesper", "Yew" })]
public abstract class Town : IComparable, IComparable<Town>
public abstract class Town : IComparable<Town>
{
public const int SilverCaptureBonus = 10000;
@ -134,12 +134,7 @@ namespace Server.Factions
public int CompareTo(Town other)
{
return Definition.Sort - other.Definition.Sort;
}
public int CompareTo(object obj)
{
return Definition.Sort - ((Town)obj).Definition.Sort;
return Definition.Sort - (other?.Definition.Sort ?? 0);
}
public static Town FromRegion(Region reg)