chore: Cleans up pattern checks. (#892)

This commit is contained in:
Kamron Batman 2021-12-24 15:53:59 -08:00 • committed by GitHub
parent 171df32257
commit 63e1b02d93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
283 changed files with 587 additions and 702 deletions

View file

@ -186,7 +186,7 @@ namespace Server.Engines.ConPVP
if (info.IsSwitched(1))
{
if (!(m_Challenged is PlayerMobile pm))
if (m_Challenged is not PlayerMobile pm)
{
return;
}

View file

@ -99,7 +99,7 @@ namespace Server.Engines.ConPVP
public static bool IsFreeConsume(Mobile mob)
{
if (!(mob is PlayerMobile pm) || pm.DuelContext?.m_EventGame == null)
if (mob is not PlayerMobile pm || pm.DuelContext?.m_EventGame == null)
{
return false;
}
@ -257,7 +257,7 @@ namespace Server.Engines.ConPVP
public static bool AllowSpecialAbility(Mobile from, string name, bool message)
{
if (!(from is PlayerMobile pm))
if (@from is not PlayerMobile pm)
{
return true;
}
@ -345,7 +345,7 @@ namespace Server.Engines.ConPVP
return false;
}
if (!(weapon is BaseRanged) && !Ruleset.GetOption("Weapons", "Melee"))
if (weapon is not BaseRanged && !Ruleset.GetOption("Weapons", "Melee"))
{
return false;
}
@ -411,7 +411,7 @@ namespace Server.Engines.ConPVP
return true;
}
if (!(item is BaseRefreshPotion))
if (item is not BaseRefreshPotion)
{
if (CantDoAnything(from))
{
@ -513,7 +513,7 @@ namespace Server.Engines.ConPVP
return false;
}
if (item is BasePotion && !(item is BaseExplosionPotion) && !(item is BaseRefreshPotion) && IsSuddenDeath)
if (item is BasePotion && item is not BaseExplosionPotion && item is not BaseRefreshPotion && IsSuddenDeath)
{
from.SendMessage(0x22, "You may not drink potions in sudden death.");
return false;
@ -655,7 +655,7 @@ namespace Server.Engines.ConPVP
public void Requip(Mobile from, Container cont)
{
if (!(cont is Corpse corpse))
if (cont is not Corpse corpse)
{
return;
}
@ -670,7 +670,7 @@ namespace Server.Engines.ConPVP
{
var item = items[i];
if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || !item.Movable)
if (item.Layer is Layer.Hair or Layer.FacialHair || !item.Movable)
{
continue;
}
@ -1295,7 +1295,7 @@ namespace Server.Engines.ConPVP
private static void EventSink_Login(Mobile m)
{
if (!(m is PlayerMobile pm))
if (m is not PlayerMobile pm)
{
return;
}
@ -1385,7 +1385,7 @@ namespace Server.Engines.ConPVP
return;
}
if (!(e.Mobile is PlayerMobile pm))
if (e.Mobile is not PlayerMobile pm)
{
return;
}
@ -2048,7 +2048,7 @@ namespace Server.Engines.ConPVP
int number = item switch
{
BaseWeapon _ => 1062001, // You can no longer wield your ~1_WEAPON~
_ when !(item is BaseShield) && (item is BaseArmor || item is BaseClothing) => 1062002, // You can no longer wear your ~1_ARMOR~
not BaseShield when item is BaseArmor or BaseClothing => 1062002, // You can no longer wear your ~1_ARMOR~
_ => 1062003 // You can no longer equip your ~1_SHIELD~
};
@ -2403,7 +2403,7 @@ namespace Server.Engines.ConPVP
m_GateFacet = Initiator.Map;
}
if (!(arena.Teleporter is ExitTeleporter tp))
if (arena.Teleporter is not ExitTeleporter tp)
{
arena.Teleporter = tp = new ExitTeleporter();
tp.MoveToWorld(arena.GateOut == Point3D.Zero ? arena.Outside : arena.GateOut, arena.Facet);

View file

@ -210,7 +210,7 @@ namespace Server.Engines.ConPVP
return false;
}
if (!(obj is IPoint3D))
if (obj is not IPoint3D)
{
return false;
}
@ -1680,7 +1680,7 @@ namespace Server.Engines.ConPVP
public int GetTeamID(Mobile mob)
{
if (!(mob is PlayerMobile pm))
if (mob is not PlayerMobile pm)
{
return mob is BaseCreature creature ? creature.Team - 1 : -1;
}

View file

@ -953,7 +953,7 @@ namespace Server.Engines.ConPVP
public int GetTeamID(Mobile mob)
{
if (!(mob is PlayerMobile pm))
if (mob is not PlayerMobile pm)
{
return -1;
}

View file

@ -553,7 +553,7 @@ namespace Server.Engines.ConPVP
public int GetTeamID(Mobile mob)
{
if (!(mob is PlayerMobile pm))
if (mob is not PlayerMobile pm)
{
return -1;
}

View file

@ -924,7 +924,7 @@ namespace Server.Engines.ConPVP
public int GetTeamID(Mobile mob)
{
if (!(mob is PlayerMobile pm))
if (mob is not PlayerMobile pm)
{
return mob is BaseCreature creature ? creature.Team - 1 : -1;
}

View file

@ -318,7 +318,7 @@ namespace Server.Engines.ConPVP
if (info.IsSwitched(1))
{
if (!(mob is PlayerMobile pm))
if (mob is not PlayerMobile pm)
{
return;
}

View file

@ -565,7 +565,7 @@ namespace Server.Engines.ConPVP
private void AddPlayer_OnTarget(Mobile from, object obj)
{
if (!(obj is Mobile mob) || mob == from)
if (obj is not Mobile mob || mob == from)
{
m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players));
@ -604,7 +604,7 @@ namespace Server.Engines.ConPVP
}
else
{
if (!(mob is PlayerMobile pm))
if (mob is not PlayerMobile pm)
{
return;
}

View file

@ -217,7 +217,7 @@ namespace Server.Engines.ConPVP
return;
}
if (!(targeted is Mobile mob))
if (targeted is not Mobile mob)
{
from.SendMessage("That is not a player.");
}
@ -238,7 +238,7 @@ namespace Server.Engines.ConPVP
}
else
{
if (!(mob is PlayerMobile pm))
if (mob is not PlayerMobile pm)
{
return;
}

View file

@ -211,7 +211,7 @@ namespace Server.Engines.ConPVP
{
case 1: // okay
{
if (!(m_From is PlayerMobile pm))
if (m_From is not PlayerMobile pm)
{
break;
}

View file

@ -306,7 +306,7 @@ namespace Server.Engines.ConPVP
}
case TourneyBracketGumpType.Participant_Info:
{
if (!(obj is TourneyParticipant part))
if (obj is not TourneyParticipant part)
{
break;
}
@ -380,7 +380,7 @@ namespace Server.Engines.ConPVP
AddLeftArrow(25, 11, ToButtonID(0, 3));
AddHtml(25, 35, 250, 20, Center("Participants"));
if (!(obj is Mobile mob))
if (obj is not Mobile mob)
{
break;
}
@ -428,7 +428,7 @@ namespace Server.Engines.ConPVP
AddLeftArrow(25, 11, ToButtonID(0, 2));
AddHtml(25, 35, 250, 20, Center("Rounds"));
if (!(m_Object is PyramidLevel level))
if (m_Object is not PyramidLevel level)
{
break;
}
@ -490,9 +490,7 @@ namespace Server.Engines.ConPVP
}
}
else if (m_Tournament.EventController != null ||
m_Tournament.TourneyType == TourneyType.RandomTeam ||
m_Tournament.TourneyType == TourneyType.RedVsBlue ||
m_Tournament.TourneyType == TourneyType.Faction)
m_Tournament.TourneyType is TourneyType.RandomTeam or TourneyType.RedVsBlue or TourneyType.Faction)
{
for (var j = 0; j < match.Participants.Count; ++j)
{
@ -572,7 +570,7 @@ namespace Server.Engines.ConPVP
}
case TourneyBracketGumpType.Match_Info:
{
if (!(obj is TourneyMatch match))
if (obj is not TourneyMatch match)
{
break;
}
@ -605,9 +603,7 @@ namespace Server.Engines.ConPVP
}
}
else if (m_Tournament.EventController != null ||
m_Tournament.TourneyType == TourneyType.RandomTeam ||
m_Tournament.TourneyType == TourneyType.RedVsBlue ||
m_Tournament.TourneyType == TourneyType.Faction)
m_Tournament.TourneyType is TourneyType.RandomTeam or TourneyType.RedVsBlue or TourneyType.Faction)
{
for (var i = 0; i < match.Participants.Count; ++i)
{
@ -840,7 +836,7 @@ namespace Server.Engines.ConPVP
}
case 5:
{
if (!(m_Object is TourneyMatch match))
if (m_Object is not TourneyMatch match)
{
break;
}
@ -990,7 +986,7 @@ namespace Server.Engines.ConPVP
break;
}
if (!(m_Object is PyramidLevel level))
if (m_Object is not PyramidLevel level)
{
break;
}

View file

@ -211,7 +211,7 @@ namespace Server.Engines.ConPVP
{
var x = ourLevel - theirLevel;
if (x < -6 || x > +6)
if (x is < -6 or > +6)
{
return 0;
}

View file

@ -16,7 +16,7 @@ namespace Server.Engines.ConPVP
{
var copy = new List<TourneyParticipant>(participants);
if (groupType == GroupingType.Nearest || groupType == GroupingType.HighVsLow)
if (groupType is GroupingType.Nearest or GroupingType.HighVsLow)
{
copy.Sort();
}