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

@ -32,7 +32,7 @@ namespace Server.Items
{
var dir = PlayerMobile.GetDirection4(from.Location, Location);
if (dir == Direction.North || dir == Direction.South)
if (dir is Direction.North or Direction.South)
{
ItemID = 0xA55;
}

View file

@ -133,7 +133,7 @@ namespace Server.Items
return;
}
if (!(obj is IPoint3D p3D))
if (obj is not IPoint3D p3D)
{
return;
}
@ -216,7 +216,7 @@ namespace Server.Items
Effects.SendLocationEffect(p, Map, 0x352D, 16, 4);
Effects.PlaySound(p, Map, 0x364);
}
else if (index <= 7 || index == 14)
else if (index is <= 7 or 14)
{
if (RequireDeepWater)
{
@ -397,7 +397,7 @@ namespace Server.Items
private static bool ValidateUndeepWater(Map map, object obj, ref int z)
{
if (!(obj is StaticTarget))
if (obj is not StaticTarget)
{
return false;
}

View file

@ -168,7 +168,7 @@ namespace Server.Items
return;
}
if (!(from is PlayerMobile pm))
if (@from is not PlayerMobile pm)
{
return;
}

View file

@ -258,7 +258,7 @@ namespace Server.Items
public override bool OnDragDrop(Mobile from, Item item)
{
if (!(item is BasePotion pot))
if (item is not BasePotion pot)
{
from.SendLocalizedMessage(502232); // The keg is not designed to hold that type of object.
return false;

View file

@ -103,7 +103,7 @@ namespace Server.Items
// if (keg == null)
// continue;
if (keg.Held <= 0 || keg.Held >= 100)
if (keg.Held is <= 0 or >= 100)
{
continue;
}

View file

@ -162,7 +162,7 @@ namespace Server.Items
return;
}
if (!(targeted is IPoint3D p) || from.Map == null)
if (targeted is not IPoint3D p || from.Map == null)
{
return;
}

View file

@ -365,7 +365,7 @@ namespace Server.Items
public override void OnAfterDuped(Item newItem)
{
if (!(newItem is Runebook book))
if (newItem is not Runebook book)
{
return;
}

View file

@ -600,7 +600,7 @@ namespace Server.Items
public override void OnAfterDuped(Item newItem)
{
if (!(newItem is Spellbook book))
if (newItem is not Spellbook book)
{
return;
}

View file

@ -74,7 +74,7 @@ namespace Server.Items
private static void EventSink_BandageTargetRequest(Mobile from, Item item, Mobile target)
{
if (!(item is Bandage b) || b.Deleted)
if (item is not Bandage b || b.Deleted)
{
return;
}

View file

@ -234,7 +234,7 @@ namespace Server.Items
public static void OnPickedInstrument(Mobile from, object targeted, InstrumentPickedCallback callback)
{
if (!(targeted is BaseInstrument instrument))
if (targeted is not BaseInstrument instrument)
{
from.SendLocalizedMessage(500619); // That is not a musical instrument.
}
@ -286,7 +286,7 @@ namespace Server.Items
val += 100;
}
if (targ is VampireBat || targ is VampireBatFamiliar)
if (targ is VampireBat or VampireBatFamiliar)
{
val += 100;
}

View file

@ -178,7 +178,7 @@ namespace Server.Items
}
}
}
else if ((item is Runebook || item is RecallRune) && m_Tub.AllowRunebooks)
else if (item is Runebook or RecallRune && m_Tub.AllowRunebooks)
{
if (!from.InRange(m_Tub.GetWorldLocation(), 1) || !from.InRange(item.GetWorldLocation(), 1))
{
@ -211,9 +211,7 @@ namespace Server.Items
}
}
else if ((item is BaseArmor armor &&
(armor.MaterialType == ArmorMaterialType.Leather ||
armor.MaterialType == ArmorMaterialType.Studded) || item is ElvenBoots ||
item is WoodlandBelt) && m_Tub.AllowLeather)
armor.MaterialType is ArmorMaterialType.Leather or ArmorMaterialType.Studded || item is ElvenBoots or WoodlandBelt) && m_Tub.AllowLeather)
{
if (!from.InRange(m_Tub.GetWorldLocation(), 1) || !from.InRange(item.GetWorldLocation(), 1))
{

View file

@ -84,7 +84,7 @@ namespace Server.Items
}
else if (targeted is Item item && !item.Movable)
{
if (item is IScissorable obj && (obj is PlagueBeastInnard || obj is PlagueBeastMutationCore))
if (item is IScissorable obj && obj is PlagueBeastInnard or PlagueBeastMutationCore)
{
if (CanScissor(from, obj) && obj.Scissor(from, m_Item))
{
@ -107,7 +107,7 @@ namespace Server.Items
protected override void OnNonlocalTarget(Mobile from, object targeted)
{
if (targeted is IScissorable obj && (obj is PlagueBeastInnard || obj is PlagueBeastMutationCore))
if (targeted is IScissorable obj && obj is PlagueBeastInnard or PlagueBeastMutationCore)
{
if (CanScissor(from, obj) && obj.Scissor(from, m_Item))
{

View file

@ -126,7 +126,7 @@ namespace Server.Items
return;
}
if (m_Item.LockLevel == 0 || m_Item.LockLevel == -255)
if (m_Item.LockLevel is 0 or -255)
{
// LockLevel of 0 means that the door can't be picklocked
// LockLevel of -255 means it's magic locked

View file

@ -50,7 +50,7 @@ namespace Server.Items
{
var qs = player.Quest;
if (!(qs is WitchApprenticeQuest))
if (qs is not WitchApprenticeQuest)
{
return;
}
@ -61,7 +61,7 @@ namespace Server.Items
{
Clock.GetTime(from.Map, from.X, from.Y, out var hours, out int _);
if (hours < 5 || hours > 17)
if (hours is < 5 or > 17)
{
player.SendLocalizedMessage(
1055040

View file

@ -141,14 +141,14 @@ namespace Server.Items
{
var check = m.FindItemOnLayer(Layer.OneHanded);
if (check is BaseTool && check != tool && !(check is AncientSmithyHammer))
if (check is BaseTool && check != tool && check is not AncientSmithyHammer)
{
return false;
}
check = m.FindItemOnLayer(Layer.TwoHanded);
return !(check is BaseTool) || check == tool || check is AncientSmithyHammer;
return check is not BaseTool || check == tool || check is AncientSmithyHammer;
}
public override void OnSingleClick(Mobile from)

View file

@ -79,7 +79,7 @@ namespace Server.Items
var version = reader.ReadInt();
if (ItemID == 0x13E4 || ItemID == 0x13E3)
if (ItemID is 0x13E4 or 0x13E3)
{
ItemID = 0xF9D;
}