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

@ -41,11 +41,11 @@ namespace Server.Items
}
else if (East)
{
canThrow = dir == Direction.Left || dir == Direction.West || dir == Direction.Up;
canThrow = dir is Direction.Left or Direction.West or Direction.Up;
}
else
{
canThrow = dir == Direction.Up || dir == Direction.North || dir == Direction.Right;
canThrow = dir is Direction.Up or Direction.North or Direction.Right;
}
if (canThrow)
@ -60,7 +60,7 @@ namespace Server.Items
public void Throw(Mobile from)
{
if (!(from.Weapon is BaseKnife knife))
if (@from.Weapon is not BaseKnife knife)
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500751); // Try holding a knife...
return;

View file

@ -598,7 +598,7 @@ namespace Server.Items
); // Not sure since when, but right now 15 points are added, not 14.
}
if (Core.ML && !(this is BaseShield))
if (Core.ML && this is not BaseShield)
{
var bonus = (int)(from.Skills.ArmsLore.Value / 20);
@ -820,7 +820,7 @@ namespace Server.Items
public override void OnAfterDuped(Item newItem)
{
if (!(newItem is BaseArmor armor))
if (newItem is not BaseArmor armor)
{
return;
}

View file

@ -33,7 +33,7 @@ namespace Server.Items
{
var from = state.Mobile;
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BaseBook book || !book.Writable ||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
{
return;
@ -52,7 +52,7 @@ namespace Server.Items
{
var from = state.Mobile;
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BaseBook book || !book.Writable ||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
{
return;
@ -88,7 +88,7 @@ namespace Server.Items
{
var from = state.Mobile;
if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable ||
if (World.FindItem((Serial)reader.ReadUInt32()) is not BaseBook book || !book.Writable ||
!from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
{
return;

View file

@ -144,7 +144,7 @@ namespace Server.Items
private static void Link_OnFirstTarget(Mobile from, object targeted)
{
if (!(targeted is BaseDoor door))
if (targeted is not BaseDoor door)
{
from.BeginTarget(-1, false, TargetFlags.None, Link_OnFirstTarget);
from.SendMessage("That is not a door. Try again.");
@ -158,7 +158,7 @@ namespace Server.Items
private static void Link_OnSecondTarget(Mobile from, object targeted, BaseDoor first)
{
if (!(targeted is BaseDoor second))
if (targeted is not BaseDoor second)
{
from.BeginTarget(-1, false, TargetFlags.None, Link_OnSecondTarget, first);
from.SendMessage("That is not a door. Try again.");
@ -180,7 +180,7 @@ namespace Server.Items
private static void ChainLink_OnTarget(Mobile from, object targeted, List<BaseDoor> list)
{
if (!(targeted is BaseDoor door))
if (targeted is not BaseDoor door)
{
from.BeginTarget(-1, false, TargetFlags.None, ChainLink_OnTarget, list);
from.SendMessage("That is not a door. Try again.");
@ -328,8 +328,8 @@ namespace Server.Items
{
var item = items[i];
if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y) &&
!(item is BaseDoor))
if (item is not BaseMulti && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y) &&
item is not BaseDoor)
{
var id = item.ItemData;
var surface = id.Surface;

View file

@ -10,7 +10,7 @@ namespace Server.Items
[Constructible]
public Vines(int v) : base(0xCEB)
{
if (v < 0 || v > 7)
if (v is < 0 or > 7)
{
v = 0;
}

View file

@ -76,7 +76,7 @@ namespace Server.Items
{
var item = list[i];
if (!(item is Container) && item.StackWith(from, dropped, false))
if (item is not Container && item.StackWith(from, dropped, false))
{
return true;
}

View file

@ -646,11 +646,11 @@ namespace Server.Items
(int)KeyType.Rusty
);
}
else if (item is Arrow || item is Bolt)
else if (item is Arrow or Bolt)
{
item.Amount = Utility.RandomMinMax(2, 6);
}
else if (item is Bandage || item is Lockpick)
else if (item is Bandage or Lockpick)
{
item.Amount = Utility.RandomMinMax(1, 3);
}

View file

@ -356,7 +356,7 @@ namespace Server.Items
return false;
}
if (c is Armoire || c is FancyArmoire)
if (c is Armoire or FancyArmoire)
{
Timer t = new FurnitureTimer(c, m);
t.Start();
@ -382,7 +382,7 @@ namespace Server.Items
t.Stop();
}
if (c is Armoire || c is FancyArmoire)
if (c is Armoire or FancyArmoire)
{
c.ItemID = c.ItemID switch
{

View file

@ -157,13 +157,12 @@ namespace Server.Items
{
foreach (var i in Items)
{
if (!(i is IScissorable) || i.Deleted)
if (i is not IScissorable || i.Deleted)
{
continue;
}
if (i is BaseClothing || i is Cloth || i is BoltOfCloth || i is Hides || i is BonePile ||
i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Leather)
if (i is BaseClothing or Cloth or BoltOfCloth or Hides or BonePile || i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Leather)
{
return true;
}
@ -249,7 +248,7 @@ namespace Server.Items
{
var item = scissorables[i];
if (!(item is IScissorable scissorable))
if (item is not IScissorable scissorable)
{
continue;
}

View file

@ -110,7 +110,7 @@ namespace Server.Items
return;
}
if (!(obj is SwampDragon pet) || pet.HasBarding)
if (obj is not SwampDragon pet || pet.HasBarding)
{
from.SendLocalizedMessage(1053025); // That is not an unarmored swamp dragon.
}

View file

@ -146,7 +146,7 @@ namespace Server.Items
return;
}
if (info.ButtonID < 1 || info.ButtonID > 10)
if (info.ButtonID is < 1 or > 10)
{
return;
}

View file

@ -89,7 +89,7 @@ namespace Server.Items
public void Placement_OnTarget(Mobile from, object targeted, HolidayTreeType type)
{
if (!(targeted is IPoint3D p))
if (targeted is not IPoint3D p)
{
return;
}

View file

@ -274,7 +274,7 @@ namespace Server.Items
return;
}
if (!(targeted is IPoint3D location))
if (targeted is not IPoint3D location)
{
return;
}

View file

@ -262,7 +262,7 @@ namespace Server.Items
public override int ComputeItemID()
{
if (ItemID == 0x99A || ItemID == 0x9B3 || ItemID == 0x9BF || ItemID == 0x9CB)
if (ItemID is 0x99A or 0x9B3 or 0x9BF or 0x9CB)
{
return ItemID;
}
@ -420,7 +420,7 @@ namespace Server.Items
{
if (IsEmpty)
{
if (ItemID == 0x9A7 || ItemID == 0xFF7)
if (ItemID is 0x9A7 or 0xFF7)
{
return ItemID;
}
@ -477,7 +477,7 @@ namespace Server.Items
}
case BeverageType.Water:
{
if (ItemID == 0xFF8 || ItemID == 0xFF9 || ItemID == 0x1F9E)
if (ItemID is 0xFF8 or 0xFF9 or 0x1F9E)
{
return ItemID;
}
@ -854,7 +854,7 @@ namespace Server.Items
{
var qs = player.Quest;
if (!(qs is WitchApprenticeQuest))
if (qs is not WitchApprenticeQuest)
{
return;
}
@ -986,7 +986,7 @@ namespace Server.Items
item.Pour(from, this);
}
else if (targ is AddonComponent component &&
(component.Addon is WaterVatEast || component.Addon is WaterVatSouth) &&
component.Addon is WaterVatEast or WaterVatSouth &&
Content == BeverageType.Water)
{
if (from is PlayerMobile player)
@ -1070,7 +1070,7 @@ namespace Server.Items
for (var i = 0; i < items.Length; ++i)
{
if (!(items[i] is BaseBeverage bev) || bev.Content != content || bev.IsEmpty)
if (items[i] is not BaseBeverage bev || bev.Content != content || bev.IsEmpty)
{
continue;
}

View file

@ -44,7 +44,7 @@ namespace Server.Items
return;
}
if (!(targeted is Item targetItem) || targetItem.Deleted)
if (targeted is not Item targetItem || targetItem.Deleted)
{
return;
}
@ -390,7 +390,7 @@ namespace Server.Items
{
Delete();
}
else if (m_Quantity < 20 && (ItemID == 0x1039 || ItemID == 0x1045))
else if (m_Quantity < 20 && ItemID is 0x1039 or 0x1045)
{
++ItemID;
}
@ -440,7 +440,7 @@ namespace Server.Items
return;
}
if (ItemID == 0x1039 || ItemID == 0x1045)
if (ItemID is 0x1039 or 0x1045)
{
++ItemID;
}

View file

@ -116,7 +116,7 @@ namespace Server.Items
public static bool ValidateDefault(Mobile from, BaseBoard board) =>
!board.Deleted && (from.AccessLevel >= AccessLevel.GameMaster || from.Alive &&
(board.IsChildOf(from.Backpack) || !(board.RootParent is Mobile) &&
(board.IsChildOf(from.Backpack) || board.RootParent is not Mobile &&
board.Map == from.Map && from.InRange(board.GetWorldLocation(), 1) &&
BaseHouse.FindHouseAt(board)?.IsOwner(from) == true));

View file

@ -33,7 +33,7 @@ namespace Server.Engines.Mahjong
public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction)
{
if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down)
if (direction is MahjongPieceDirection.Up or MahjongPieceDirection.Down)
{
return new MahjongPieceDim(position, 40, 20);
}

View file

@ -51,7 +51,7 @@ namespace Server.Engines.Mahjong
public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction)
{
if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down)
if (direction is MahjongPieceDirection.Up or MahjongPieceDirection.Down)
{
return new MahjongPieceDim(position, 20, 30);
}

View file

@ -431,7 +431,7 @@ namespace Server.Items
public void Placement_OnTarget(Mobile from, object targeted)
{
if (!(targeted is IPoint3D p) || Deleted)
if (targeted is not IPoint3D p || Deleted)
{
return;
}

View file

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

View file

@ -11,7 +11,7 @@ namespace Server.Items
public override void Ignite()
{
if (!(Parent is Mobile) && RootParent is Mobile holder)
if (Parent is not Mobile && RootParent is Mobile holder)
{
if (holder.EquipItem(this))
{

View file

@ -29,7 +29,7 @@ namespace Server.Items
{
get
{
if (ItemID == 0x1583 || ItemID == 0x1854)
if (ItemID is 0x1583 or 0x1854)
{
return 0x1854;
}
@ -42,7 +42,7 @@ namespace Server.Items
{
get
{
if (ItemID == 0x1853 || ItemID == 0x1584)
if (ItemID is 0x1853 or 0x1584)
{
return 0x1853;
}

View file

@ -29,7 +29,7 @@ namespace Server.Items
{
get
{
if (ItemID == 0xA15 || ItemID == 0xA17)
if (ItemID is 0xA15 or 0xA17)
{
return ItemID;
}

View file

@ -29,7 +29,7 @@ namespace Server.Network
{
var from = state.Mobile;
if (!(World.FindItem((Serial)reader.ReadUInt32()) is MapItem map))
if (World.FindItem((Serial)reader.ReadUInt32()) is not MapItem map)
{
return;
}

View file

@ -68,13 +68,13 @@ namespace Server.Items
new Bola().MoveToWorld(to.Location, to.Map);
}
if (to is ChaosDragoon || to is ChaosDragoonElite)
if (to is ChaosDragoon or ChaosDragoonElite)
{
from.SendLocalizedMessage(1042047); // You fail to knock the rider from its mount.
}
var mt = to.Mount;
if (mt != null && !(to is ChaosDragoon || to is ChaosDragoonElite))
if (mt != null && !(to is ChaosDragoon or ChaosDragoonElite))
{
mt.Rider = null;
}

View file

@ -121,7 +121,7 @@ namespace Server.Items
public override void OnSpeech(SpeechEventArgs e)
{
if (!Active || Receivers.Count == 0 || RootParent != null && !(RootParent is Mobile))
if (!Active || Receivers.Count == 0 || RootParent != null && RootParent is not Mobile)
{
return;
}

View file

@ -789,7 +789,7 @@ namespace Server.Items
public bool DevourCorpse()
{
if (Devoured || Deleted || Killer?.Deleted != false || !Killer.Alive || !(Killer is IDevourer devourer) ||
if (Devoured || Deleted || Killer?.Deleted != false || !Killer.Alive || Killer is not IDevourer devourer ||
Owner?.Deleted != false)
{
return false;
@ -1003,8 +1003,7 @@ namespace Server.Items
var item = items[i];
var loc = item.Location;
if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || !item.Movable ||
!GetRestoreInfo(item, ref loc))
if (item.Layer is Layer.Hair or Layer.FacialHair || !item.Movable || !GetRestoreInfo(item, ref loc))
{
continue;
}
@ -1055,7 +1054,7 @@ namespace Server.Items
return;
}
if (!(from is PlayerMobile player))
if (@from is not PlayerMobile player)
{
return;
}

View file

@ -24,7 +24,7 @@ namespace Server.Items
{
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that
}
else if (Visible && (ItemID == 4656 || ItemID == 4702) && Core.Now >= m_NextUse)
else if (Visible && ItemID is 4656 or 4702 && Core.Now >= m_NextUse)
{
var p = GetWorldLocation();
@ -89,11 +89,11 @@ namespace Server.Items
private void BackUp()
{
if (ItemID == 4678 || ItemID == 4679)
if (ItemID is 4678 or 4679)
{
ItemID = 4656;
}
else if (ItemID == 4712 || ItemID == 4713)
else if (ItemID is 4712 or 4713)
{
ItemID = 4702;
}
@ -112,11 +112,11 @@ namespace Server.Items
int version = reader.ReadByte();
if (ItemID == 4678 || ItemID == 4679)
if (ItemID is 4678 or 4679)
{
ItemID = 4656;
}
else if (ItemID == 4712 || ItemID == 4713)
else if (ItemID is 4712 or 4713)
{
ItemID = 4702;
}

View file

@ -29,7 +29,7 @@ namespace Server.Items
return false;
}
if (!(dropped is Key key) || key.KeyValue == 0)
if (dropped is not Key key || key.KeyValue == 0)
{
from.SendLocalizedMessage(501689); // Only non-blank keys can be put on a keyring.
return false;
@ -80,7 +80,7 @@ namespace Server.Items
public void Open(Mobile from)
{
if (!(Parent is Container cont))
if (Parent is not Container cont)
{
return;
}

View file

@ -66,7 +66,7 @@ namespace Server.Items
foreach (var m in GetMobilesInRange(0))
{
if (m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned))
if (m.Alive && !m.IsDeadBondedPet && (m is not BaseCreature bc || bc.Controlled || bc.Summoned))
{
toDamage.Add(m);
}

View file

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

View file

@ -63,7 +63,7 @@ namespace Server.Items
return true;
}
if (!(m.Guild is Guild g) || g.Type != GuildType.Chaos)
if (m.Guild is not Guild g || g.Type != GuildType.Chaos)
{
m.FixedEffect(0x3728, 10, 13);
Delete();

View file

@ -68,7 +68,7 @@ namespace Server.Items
return true;
}
if (!(m.Guild is Guild g) || g.Type != GuildType.Order)
if (m.Guild is not Guild g || g.Type != GuildType.Order)
{
m.FixedEffect(0x3728, 10, 13);
Delete();

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;
}

View file

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

View file

@ -27,7 +27,7 @@ namespace Server.Items
{
Clock.GetTime(Map, X, Y, out var hours, out int _);
if (hours < 4 || hours > 20)
if (hours is < 4 or > 20)
{
Effects.PlaySound(Location, Map, 0x569);
}

View file

@ -35,7 +35,7 @@ namespace Server.Items
{
if (!Utility.InRange(old, Location, 2) && Utility.InRange(m.Location, Location, 2))
{
if (ItemID == 0x2A69 || ItemID == 0x2A6D)
if (ItemID is 0x2A69 or 0x2A6D)
{
Up();
Timer.StartTimer(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), 2, Up);
@ -43,7 +43,7 @@ namespace Server.Items
}
else if (Utility.InRange(old, Location, 2) && !Utility.InRange(m.Location, Location, 2))
{
if (ItemID == 0x2A6C || ItemID == 0x2A70)
if (ItemID is 0x2A6C or 0x2A70)
{
Down();
Timer.StartTimer(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), 2, Down);

View file

@ -22,7 +22,7 @@ namespace Server.Items
{
if (!Utility.InRange(old, Location, 2) && Utility.InRange(m.Location, Location, 2))
{
if (ItemID == 0x2A7B || ItemID == 0x2A7D)
if (ItemID is 0x2A7B or 0x2A7D)
{
Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x551, 0x553));
ItemID += 1;
@ -30,7 +30,7 @@ namespace Server.Items
}
else if (Utility.InRange(old, Location, 2) && !Utility.InRange(m.Location, Location, 2))
{
if (ItemID == 0x2A7C || ItemID == 0x2A7E)
if (ItemID is 0x2A7C or 0x2A7E)
{
ItemID -= 1;
}

View file

@ -87,7 +87,7 @@ namespace Server.Items
public virtual void Activate(AddonComponent c, Mobile from)
{
if (c.ItemID == 0x125E || c.ItemID == 0x1269 || c.ItemID == 0x1260)
if (c.ItemID is 0x125E or 0x1269 or 0x1260)
{
c.ItemID = 0x1269;
}

View file

@ -160,7 +160,7 @@ namespace Server.Items
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Deed?.Deleted != false || info.ButtonID == 0 || info.ButtonID < 1 || info.ButtonID > 8)
if (m_Deed?.Deleted != false || info.ButtonID is 0 or < 1 or > 8)
{
return;
}

View file

@ -227,7 +227,7 @@ namespace Server.Items
public void Placement_OnTarget(Mobile from, object targeted)
{
if (!(targeted is IPoint3D p))
if (targeted is not IPoint3D p)
{
return;
}

View file

@ -299,7 +299,7 @@ namespace Server.Items
private bool HasEntered(Mobile from)
{
if (!(from.Account is Account acc))
if (@from.Account is not Account acc)
{
return false;
}
@ -509,7 +509,7 @@ namespace Server.Items
return;
}
if (!(from.Account is Account))
if (@from.Account is not Account)
{
return;
}

View file

@ -113,7 +113,7 @@ namespace Server.Items
public override bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage)
{
if (dropped is PlagueBeastInnard || dropped is PlagueBeastGland)
if (dropped is PlagueBeastInnard or PlagueBeastGland)
{
return base.TryDropItem(from, dropped, sendFullMessage);
}
@ -123,7 +123,7 @@ namespace Server.Items
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
{
if (IsAccessibleTo(from) && (item is PlagueBeastInnard || item is PlagueBeastGland))
if (IsAccessibleTo(from) && item is PlagueBeastInnard or PlagueBeastGland)
{
var ir = ItemBounds.Table[item.ItemID];
int x, y;

View file

@ -258,7 +258,7 @@ namespace Server.Items
0x59
); // You may only send items from your backpack to your bank box.
}
else if (item is BagOfSending || item is Container)
else if (item is BagOfSending or Container)
{
from.NetState.SendMessage(
m_Bag.Serial,

View file

@ -412,7 +412,7 @@ namespace Server.Items
if (m_Bracelet.Deleted || m_From.Deleted ||
!m_Bracelet.CheckUse(m_From, false) ||
!(m_Bracelet.Bound.RootParent is Mobile boundRoot))
m_Bracelet.Bound.RootParent is not Mobile boundRoot)
{
return;
}

View file

@ -167,7 +167,7 @@ namespace Server.Items
return false;
}
if (Account != null && (!(from.Account is Account) || from.Account.Username != Account))
if (Account != null && (@from.Account is not Accounting.Account || from.Account.Username != Account))
{
from.SendLocalizedMessage(
1070714
@ -993,7 +993,7 @@ namespace Server.Items
if (version <= 1)
{
if (ItemID == 0x2A93 || ItemID == 0x2A94)
if (ItemID is 0x2A93 or 0x2A94)
{
ActiveItemID = Utility.Random(0x2AA1, 9);
}

View file

@ -72,7 +72,7 @@ namespace Server.Items
{
Hue = 0x481;
if (Value == 105.0 || skill == SkillName.Blacksmith || skill == SkillName.Tailoring)
if (Value == 105.0 || skill is SkillName.Blacksmith or SkillName.Tailoring)
{
LootType = LootType.Regular;
}
@ -155,7 +155,7 @@ namespace Server.Items
do
{
skillName = Skills.RandomElement();
} while (skillName == SkillName.Blacksmith || skillName == SkillName.Tailoring);
} while (skillName is SkillName.Blacksmith or SkillName.Tailoring);
return new PowerScroll(skillName, 100 + Utility.RandomMinMax(min, max) * 5);
}
@ -312,7 +312,7 @@ namespace Server.Items
var version = InheritsItem ? 0 : reader.ReadInt(); // Required for SpecialScroll insertion
if (Value == 105.0 || Skill == SkillName.Blacksmith || Skill == SkillName.Tailoring)
if (Value == 105.0 || Skill is SkillName.Blacksmith or SkillName.Tailoring)
{
LootType = LootType.Regular;
}

View file

@ -106,7 +106,7 @@ namespace Server.Items
{
InheritsItem = true;
if (!(this is StatCapScroll))
if (this is not StatCapScroll)
{
Skill = (SkillName)reader.ReadInt();
}

View file

@ -157,7 +157,7 @@ namespace Server.Items
{
var from = state.Mobile;
if (info.ButtonID == 1 || info.ButtonID == 2)
if (info.ButtonID is 1 or 2)
{
if (from.Map?.CanFit(from.Location, 16, false, false) != true)
{

View file

@ -264,7 +264,7 @@ namespace Server.Items
var m = sender.Mobile;
if (info.ButtonID < Start || info.ButtonID > End || (info.ButtonID & 0x1) != 0)
if (info.ButtonID is < Start or > End || (info.ButtonID & 0x1) != 0)
{
return;
}

View file

@ -273,7 +273,7 @@ namespace Server.Items
return;
}
if (!(targeted is IPoint3D p))
if (targeted is not IPoint3D p)
{
return;
}

View file

@ -64,7 +64,7 @@ namespace Server.Items
{
var parent = deed;
while (parent != null && !(parent is CommodityDeedBox))
while (parent != null && parent is not CommodityDeedBox)
{
parent = parent.Parent as Item;
}

View file

@ -255,9 +255,8 @@ namespace Server.Items
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Shield?.Deleted != false || info.ButtonID < Start || info.ButtonID > End ||
((info.ButtonID & 0x1) != 0 || info.ButtonID >= 0x1582) &&
(info.ButtonID < 0x1582 || info.ButtonID > 0x1585))
if (m_Shield?.Deleted != false || info.ButtonID is < Start or > End || ((info.ButtonID & 0x1) != 0 || info.ButtonID >= 0x1582) &&
info.ButtonID is < 0x1582 or > 0x1585)
{
return;
}

View file

@ -27,8 +27,7 @@ namespace Server.Items
{
get
{
if (ItemID == 0x1A03 || ItemID == 0x1A05 || ItemID == 0x1A09 ||
ItemID == 0x1B1E || ItemID == 0x1B7F)
if (ItemID is 0x1A03 or 0x1A05 or 0x1A09 or 0x1B1E or 0x1B7F)
{
return true;
}

View file

@ -170,7 +170,7 @@ namespace Server.Items
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Cactus?.Deleted != false || info.ButtonID < 0x1E0F || info.ButtonID > 0x1E14)
if (m_Cactus?.Deleted != false || info.ButtonID is < 0x1E0F or > 0x1E14)
{
return;
}

View file

@ -503,7 +503,7 @@ namespace Server.Items
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_WallBanner?.Deleted != false || info.ButtonID <= 0 || info.ButtonID >= 31)
if (m_WallBanner?.Deleted != false || info.ButtonID is <= 0 or >= 31)
{
return;
}

View file

@ -47,7 +47,7 @@ namespace Server.Items
public bool Validate()
{
if (!(RootParent is Mobile mobile) || mobile.AccessLevel >= AccessLevel)
if (RootParent is not Mobile mobile || mobile.AccessLevel >= AccessLevel)
{
return true;
}

View file

@ -345,7 +345,7 @@ namespace Server.Items
public override void OnAfterDuped(Item newItem)
{
if (!(newItem is BaseTalisman talisman))
if (newItem is not BaseTalisman talisman)
{
return;
}
@ -1190,7 +1190,7 @@ namespace Server.Items
return;
}
if (!(o is Mobile target))
if (o is not Mobile target)
{
from.SendLocalizedMessage(1046439); // That is not a valid target.
return;

View file

@ -244,7 +244,7 @@ namespace Server.Items
public virtual void DoWandTarget(Mobile from, object o)
{
if (Deleted || _charges <= 0 || Parent != from || o is StaticTarget || o is LandTarget)
if (Deleted || _charges <= 0 || Parent != @from || o is StaticTarget or LandTarget)
{
return;
}

View file

@ -39,7 +39,7 @@ namespace Server.Items
return;
}
if (defender is ChaosDragoon || defender is ChaosDragoonElite)
if (defender is ChaosDragoon or ChaosDragoonElite)
{
return;
}

View file

@ -87,7 +87,7 @@ namespace Server.Items
return;
}
if (!(HarvestSystem is Mining))
if (HarvestSystem is not Mining)
{
from.SendLocalizedMessage(1010018); // What do you want to use this item on?
}

View file

@ -199,7 +199,7 @@ namespace Server.Items
{
var item = m.FindItemOnLayer(Layer.OneHanded);
return (item == null || item is Spellbook) && m.FindItemOnLayer(Layer.TwoHanded) == null;
return item is null or Spellbook && m.FindItemOnLayer(Layer.TwoHanded) == null;
}
private static void EventSink_DisarmRequest(Mobile m)

View file

@ -53,7 +53,7 @@ namespace Server.Items
if (canSwing)
{
canSwing = !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement;
canSwing = attacker.Spell is not Spell sp || !sp.IsCasting || !sp.BlocksMovement;
}
}

View file

@ -43,7 +43,7 @@ namespace Server.Items
public void OnTargetGears(Mobile from, object targ)
{
if (!(targ is Gears g) || !g.IsChildOf(from.Backpack))
if (targ is not Gears g || !g.IsChildOf(from.Backpack))
{
from.SendMessage(
"Those are not gears."