Removes old comparable/comparers. (#31)
This commit is contained in:
parent
513e54f70e
commit
a45094f2dc
23 changed files with 95 additions and 249 deletions
|
|
@ -172,7 +172,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
|
||||
[PropertyObject]
|
||||
public class Arena : IComparable
|
||||
public class Arena : IComparable<Arena>
|
||||
{
|
||||
private bool m_Active;
|
||||
private Rectangle2D m_Bounds;
|
||||
|
|
@ -456,10 +456,8 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public static List<Arena> Arenas{ get; } = new List<Arena>();
|
||||
|
||||
public int CompareTo(object obj)
|
||||
public int CompareTo(Arena c)
|
||||
{
|
||||
Arena c = (Arena)obj;
|
||||
|
||||
string a = m_Name;
|
||||
string b = c.m_Name;
|
||||
|
||||
|
|
@ -475,18 +473,13 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public Ladder AcquireLadder()
|
||||
{
|
||||
if (Ladder != null)
|
||||
return Ladder.Ladder;
|
||||
|
||||
return ConPVP.Ladder.Instance;
|
||||
return Ladder?.Ladder ?? ConPVP.Ladder.Instance;
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
Active = false;
|
||||
|
||||
m_Region?.Unregister();
|
||||
|
||||
m_Region = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1116,7 +1116,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class BRPlayerInfo : IRankedCTF, IComparable
|
||||
public sealed class BRPlayerInfo : IRankedCTF, IComparable<BRPlayerInfo>
|
||||
{
|
||||
private int m_Captures;
|
||||
|
||||
|
|
@ -1133,17 +1133,16 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public Mobile Player{ get; }
|
||||
|
||||
public int CompareTo(object obj)
|
||||
public int CompareTo(BRPlayerInfo pi)
|
||||
{
|
||||
BRPlayerInfo pi = (BRPlayerInfo)obj;
|
||||
int res = pi.Captures.CompareTo(Captures);
|
||||
if (res == 0)
|
||||
{
|
||||
res = pi.Score.CompareTo(Score);
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
if (res == 0)
|
||||
res = pi.Kills.CompareTo(Kills);
|
||||
}
|
||||
res = pi.Score.CompareTo(Score);
|
||||
|
||||
if (res == 0)
|
||||
res = pi.Kills.CompareTo(Kills);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
|
||||
[PropertyObject]
|
||||
public sealed class KHTeamInfo : IRankedCTF, IComparable
|
||||
public sealed class KHTeamInfo : IRankedCTF, IComparable<KHTeamInfo>
|
||||
{
|
||||
public KHTeamInfo(int teamID)
|
||||
{
|
||||
|
|
@ -609,30 +609,21 @@ namespace Server.Engines.ConPVP
|
|||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public string TeamName{ get; set; }
|
||||
|
||||
public int CompareTo(object obj)
|
||||
public int CompareTo(KHTeamInfo ti)
|
||||
{
|
||||
KHTeamInfo ti = (KHTeamInfo)obj;
|
||||
int res = ti.Score.CompareTo(Score);
|
||||
if (res == 0)
|
||||
{
|
||||
res = ti.Captures.CompareTo(Captures);
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
if (res == 0)
|
||||
res = ti.Kills.CompareTo(Kills);
|
||||
}
|
||||
res = ti.Captures.CompareTo(Captures);
|
||||
|
||||
if (res == 0)
|
||||
res = ti.Kills.CompareTo(Kills);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TeamName == null)
|
||||
return "(null) Team";
|
||||
return $"{TeamName} Team";
|
||||
}
|
||||
}
|
||||
public string Name => $"{TeamName ?? "(none)"} Team";
|
||||
|
||||
public int Kills{ get; set; }
|
||||
|
||||
|
|
@ -661,9 +652,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
if (TeamName != null)
|
||||
return $"({Name}) ...";
|
||||
return "...";
|
||||
return TeamName != null ? $"({Name}) ..." : "...";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
public class LadderEntry : IComparable
|
||||
public class LadderEntry : IComparable<LadderEntry>
|
||||
{
|
||||
private int m_Experience;
|
||||
private Ladder m_Ladder;
|
||||
|
|
@ -350,9 +350,9 @@ namespace Server.Engines.ConPVP
|
|||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Rank => Index;
|
||||
|
||||
public int CompareTo(object obj)
|
||||
public int CompareTo(LadderEntry l)
|
||||
{
|
||||
return ((LadderEntry)obj).m_Experience - m_Experience;
|
||||
return (l?.m_Experience ?? 0) - m_Experience;
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue