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

@ -347,9 +347,7 @@ namespace Server.Commands.Generic
{
var result = Properties.IncreaseValue(e.Mobile, obj, e.Arguments);
if (result == "The property has been increased." || result == "The properties have been increased." ||
result == "The property has been decreased." || result == "The properties have been decreased." ||
result == "The properties have been changed.")
if (result is "The property has been increased." or "The properties have been increased." or "The property has been decreased." or "The properties have been decreased." or "The properties have been changed.")
{
AddResponse(result);
}
@ -556,7 +554,7 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (!(obj is IPoint3D p))
if (obj is not IPoint3D p)
{
return;
}
@ -588,7 +586,7 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (!(obj is IPoint3D p))
if (obj is not IPoint3D p)
{
return;
}
@ -787,8 +785,7 @@ namespace Server.Commands.Generic
{
var result = Properties.GetValue(e.Mobile, obj, e.GetString(i));
if (result == "Property not found." || result == "Property is write only." ||
result.StartsWithOrdinal("Getting this property"))
if (result is "Property not found." or "Property is write only." || result.StartsWithOrdinal("Getting this property"))
{
LogFailure(result);
}
@ -1285,7 +1282,7 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (!(obj is Item item))
if (obj is not Item item)
{
return;
}

View file

@ -35,7 +35,7 @@ namespace Server.Commands.Generic
{
house = null;
if (item == null || item is BaseMulti || item is HouseSign || staticsOnly && !(item is Static))
if (item is null or BaseMulti or HouseSign || staticsOnly && item is not Static)
{
return DesignInsertResult.InvalidItem;
}

View file

@ -325,7 +325,7 @@ namespace Server.Commands.Generic
throw new InvalidOperationException("Invalid string comparison operator.");
}
if (m_Operator == StringOperator.Equal || m_Operator == StringOperator.NotEqual)
if (m_Operator is StringOperator.Equal or StringOperator.NotEqual)
{
emitter.BeginCall(
type.GetMethod(

View file

@ -44,7 +44,7 @@ namespace Server.Commands.Generic
return; // sanity check
}
if (!(targeted is Container cont))
if (targeted is not Container cont)
{
from.SendMessage("That is not a container.");
return;

View file

@ -46,7 +46,7 @@ namespace Server.Commands.Generic
{
case ObjectTypes.Both:
{
if (!(targeted is Item || targeted is Mobile))
if (!(targeted is Item or Mobile))
{
from.SendMessage("This command does not work on that.");
return;
@ -56,7 +56,7 @@ namespace Server.Commands.Generic
}
case ObjectTypes.Items:
{
if (!(targeted is Item))
if (targeted is not Item)
{
from.SendMessage("This command only works on items.");
return;
@ -66,7 +66,7 @@ namespace Server.Commands.Generic
}
case ObjectTypes.Mobiles:
{
if (!(targeted is Mobile))
if (targeted is not Mobile)
{
from.SendMessage("This command only works on mobiles.");
return;

View file

@ -52,7 +52,7 @@ namespace Server.Commands.Generic
{
case ObjectTypes.Items:
{
if (!(obj is Item))
if (obj is not Item)
{
e.Mobile.SendMessage("This command only works on items.");
return;
@ -62,7 +62,7 @@ namespace Server.Commands.Generic
}
case ObjectTypes.Mobiles:
{
if (!(obj is Mobile))
if (obj is not Mobile)
{
e.Mobile.SendMessage("This command only works on mobiles.");
return;

View file

@ -68,7 +68,7 @@ namespace Server.Commands.Generic
{
case ObjectTypes.Both:
{
if (!(targeted is Item) && !(targeted is Mobile))
if (targeted is not Item && targeted is not Mobile)
{
from.SendMessage("This command does not work on that.");
return;
@ -78,7 +78,7 @@ namespace Server.Commands.Generic
}
case ObjectTypes.Items:
{
if (!(targeted is Item))
if (targeted is not Item)
{
from.SendMessage("This command only works on items.");
return;
@ -88,7 +88,7 @@ namespace Server.Commands.Generic
}
case ObjectTypes.Mobiles:
{
if (!(targeted is Mobile))
if (targeted is not Mobile)
{
from.SendMessage("This command only works on mobiles.");
return;