Code cleanup (#195)

This commit is contained in:
Kamron Batman 2020-08-16 21:46:54 -07:00 • committed by GitHub
parent b476bcfd24
commit 0926b5abaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 740 additions and 1635 deletions

View file

@ -96,13 +96,7 @@ namespace Server.Engines.ConPVP
public Tournament Tournament => m_Tournament;
private bool CantDoAnything(Mobile mob)
{
if (m_EventGame != null)
return m_EventGame.CantDoAnything(mob);
return false;
}
private bool CantDoAnything(Mobile mob) => m_EventGame?.CantDoAnything(mob) == true;
public static bool IsFreeConsume(Mobile mob)
{

View file

@ -215,14 +215,7 @@ namespace Server.Engines.ConPVP
int zdiff = myLoc.Z - m.Z;
if (zdiff < 0)
return false;
if (zdiff < 12)
return true;
if (zdiff < 16)
return Utility.RandomBool(); // 50% chance
return false;
return zdiff >= 0 && (zdiff < 12 || zdiff < 16 && Utility.RandomBool());
}
private void DoAnim(Point3D start, Point3D end, Map map)
@ -1648,12 +1641,12 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < teams.Count; ++i)
{
TrophyRank rank = TrophyRank.Bronze;
if (i == 0)
rank = TrophyRank.Gold;
else if (i == 1)
rank = TrophyRank.Silver;
TrophyRank rank = i switch
{
0 => TrophyRank.Gold,
1 => TrophyRank.Silver,
_ => TrophyRank.Bronze
};
BRPlayerInfo leader = teams[i].Leader;
@ -1747,7 +1740,8 @@ namespace Server.Engines.ConPVP
p.Players[j].Eliminated = true;
}
m_Context.Finish(m_Context.Participants[winner.TeamID]);
if (winner != null)
m_Context.Finish(m_Context.Participants[winner.TeamID]);
}
public override void OnStop()

View file

@ -170,10 +170,8 @@ namespace Server.Engines.ConPVP
return 50;
if (xp >= 2500)
return 10 + (xp - 2500) / 500;
if (xp < 0)
xp = 0;
return m_ShortLevels[xp / 100];
return m_ShortLevels[Math.Max(xp, 0) / 100];
}
public static void GetLevelInfo(int level, out int xpBase, out int xpAdvance)

View file

@ -78,10 +78,7 @@ namespace Server.Engines.ConPVP
sb.Append(mob.Name);
}
if (sb.Length == 0)
return "Empty";
return sb.ToString();
return sb.Length == 0 ? "Empty" : sb.ToString();
}
}

View file

@ -149,24 +149,14 @@ namespace Server.Engines.ConPVP
public int ParticipantsPerMatch
{
get => m_ParticipantsPerMatch;
set
{
if (value < 2) value = 2;
else if (value > 10) value = 10;
m_ParticipantsPerMatch = value;
}
set => m_ParticipantsPerMatch = Math.Clamp(value, 2, 10);
}
[CommandProperty(AccessLevel.GameMaster)]
public int PlayersPerParticipant
{
get => m_PlayersPerParticipant;
set
{
if (value < 1) value = 1;
else if (value > 10) value = 10;
m_PlayersPerParticipant = value;
}
set => m_PlayersPerParticipant = Math.Clamp(value, 1, 10);
}
[CommandProperty(AccessLevel.GameMaster)]

View file

@ -74,10 +74,7 @@ namespace Server.Engines.ConPVP
sb.Append(mob.Name);
}
if (sb.Length == 0)
return "Empty";
return sb.ToString();
return sb.Length == 0 ? "Empty" : sb.ToString();
}
}
@ -103,4 +100,4 @@ namespace Server.Engines.ConPVP
AddLog("Match lost.");
}
}
}
}