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

@ -86,7 +86,7 @@ namespace Server.SkillHandlers
protected override void OnTarget(Mobile from, object targeted)
{
if (!(targeted is BaseBook book))
if (targeted is not BaseBook book)
{
from.SendLocalizedMessage(1046296); // That is not a book
}
@ -131,7 +131,7 @@ namespace Server.SkillHandlers
return;
}
if (!(targeted is BaseBook bookDst))
if (targeted is not BaseBook bookDst)
{
from.SendLocalizedMessage(1046296); // That is not a book
}

View file

@ -54,7 +54,7 @@ namespace Server.SkillHandlers
{
from.RevealingAction();
if (!(targeted is Mobile targ))
if (targeted is not Mobile targ)
{
from.SendLocalizedMessage(1049528); // You cannot calm that!
}

View file

@ -56,7 +56,7 @@ namespace Server.SkillHandlers
var startTimer = false;
if (targeted is Food || targeted is FukiyaDarts || targeted is Shuriken)
if (targeted is Food or FukiyaDarts or Shuriken)
{
startTimer = true;
}
@ -69,7 +69,7 @@ namespace Server.SkillHandlers
}
else if (weapon.Layer == Layer.OneHanded)
{
startTimer = weapon.Type == WeaponType.Slashing || weapon.Type == WeaponType.Piercing;
startTimer = weapon.Type is WeaponType.Slashing or WeaponType.Piercing;
}
}

View file

@ -107,7 +107,7 @@ namespace Server.SkillHandlers
{
from.SendLocalizedMessage(1049446); // You have no chance of provoking those creatures.
}
else if (creature.Unprovokable && !(creature is DemonKnight))
else if (creature.Unprovokable && creature is not DemonKnight)
{
from.SendLocalizedMessage(1049446); // You have no chance of provoking those creatures.
}

View file

@ -38,77 +38,76 @@ namespace Server.SkillHandlers
public static void Container_Snoop(Container cont, Mobile from)
{
if (from.AccessLevel > AccessLevel.Player || from.InRange(cont.GetWorldLocation(), 1))
if (from.AccessLevel <= AccessLevel.Player && !from.InRange(cont.GetWorldLocation(), 1))
{
var root = cont.RootParent as Mobile;
from.SendLocalizedMessage(500446); // That is too far away.
return;
}
if (root?.Alive == false)
var root = cont.RootParent as Mobile;
if (root?.Alive == false)
{
return;
}
if (root?.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player)
{
from.SendLocalizedMessage(500209); // You can not peek into the container.
return;
}
if (root?.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root))
{
from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target.
return;
}
if (root?.AccessLevel == AccessLevel.Player &&
from.Skills.Snooping.Value < Utility.Random(100))
{
var map = from.Map;
if (map != null)
{
return;
}
var message = $"You notice {from.Name} attempting to peek into {root.Name}'s belongings.";
if (root?.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player)
{
from.SendLocalizedMessage(500209); // You can not peek into the container.
return;
}
var eable = map.GetClientsInRange(from.Location, 8);
if (root?.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root))
{
from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target.
return;
}
if (root?.AccessLevel == AccessLevel.Player &&
from.Skills.Snooping.Value < Utility.Random(100))
{
var map = from.Map;
if (map != null)
foreach (var ns in eable)
{
var message = $"You notice {from.Name} attempting to peek into {root.Name}'s belongings.";
var eable = map.GetClientsInRange(from.Location, 8);
foreach (var ns in eable)
if (ns.Mobile != from)
{
if (ns.Mobile != from)
{
ns.Mobile.SendMessage(message);
}
ns.Mobile.SendMessage(message);
}
eable.Free();
}
}
if (from.AccessLevel == AccessLevel.Player)
{
Titles.AwardKarma(from, -4, true);
}
if (from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill(SkillName.Snooping, cont, 0.0, 100.0))
{
if (cont is TrappableContainer container && container.ExecuteTrap(from))
{
return;
}
cont.DisplayTo(from);
eable.Free();
}
else
{
from.SendLocalizedMessage(500210); // You failed to peek into the container.
}
if (from.Skills.Hiding.Value / 2 < Utility.Random(100))
{
from.RevealingAction();
}
if (from.AccessLevel == AccessLevel.Player)
{
Titles.AwardKarma(from, -4, true);
}
if (from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill(SkillName.Snooping, cont, 0.0, 100.0))
{
if (cont is TrappableContainer container && container.ExecuteTrap(from))
{
return;
}
cont.DisplayTo(from);
}
else
{
from.SendLocalizedMessage(500446); // That is too far away.
from.SendLocalizedMessage(500210); // You failed to peek into the container.
if (from.Skills.Hiding.Value / 2 < Utility.Random(100))
{
from.RevealingAction();
}
}
}
}

View file

@ -116,7 +116,7 @@ namespace Server.SkillHandlers
public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable)
{
if (type == DisturbType.EquipRequest || type == DisturbType.UseRequest)
if (type is DisturbType.EquipRequest or DisturbType.UseRequest)
{
return false;
}