Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 • committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -129,7 +129,7 @@ namespace Server.Mobiles
if (map == null)
return;
IPooledEnumerable <BaseCreature> eable = GetMobilesInRange<BaseCreature>(10);
IPooledEnumerable<BaseCreature> eable = GetMobilesInRange<BaseCreature>(10);
int rats = eable.Aggregate(0, (c, m) => c + (m is Ratman || m is RatmanArcher || m is RatmanMage ? 1 : 0));
eable.Free();
@ -158,13 +158,13 @@ namespace Server.Mobiles
public void DoSpecialAbility(Mobile target)
{
if (target?.Deleted != false) //sanity
if (target?.Deleted != false) // sanity
return;
if (0.6 >= Utility.RandomDouble()) // 60% chance to polymorph attacker into a ratman
if (Utility.RandomDouble() <= 0.6) // 60% chance to polymorph attacker into a ratman
Polymorph(target);
if (0.2 >= Utility.RandomDouble()) // 20% chance to more ratmen
if (Utility.RandomDouble() <= 0.2) // 20% chance to more ratmen
SpawnRatmen(target);
if (Hits < 500 && !IsBodyMod) // Baracoon is low on life, polymorph into a ratman
@ -201,7 +201,7 @@ namespace Server.Mobiles
private class ExpirePolymorphTimer : Timer
{
private Mobile m_Owner;
private readonly Mobile m_Owner;
public ExpirePolymorphTimer(Mobile owner) : base(TimeSpan.FromMinutes(3.0))
{

View file

@ -7,8 +7,7 @@ namespace Server.Mobiles
{
public abstract class BaseChampion : BaseCreature
{
public BaseChampion(AIType aiType, FightMode mode = FightMode.Closest) :
base(aiType, mode, 18, 1, 0.1, 0.2)
public BaseChampion(AIType aiType, FightMode mode = FightMode.Closest) : base(aiType, mode, 18, 1, 0.1, 0.2)
{
}
@ -19,12 +18,12 @@ namespace Server.Mobiles
public override bool CanMoveOverObstacles => true;
public override bool CanDestroyObstacles => true;
public abstract ChampionSkullType SkullType{ get; }
public abstract ChampionSkullType SkullType { get; }
public abstract Type[] UniqueList{ get; }
public abstract Type[] SharedList{ get; }
public abstract Type[] DecorativeList{ get; }
public abstract MonsterStatuetteType[] StatueTypes{ get; }
public abstract Type[] UniqueList { get; }
public abstract Type[] SharedList { get; }
public abstract Type[] DecorativeList { get; }
public abstract MonsterStatuetteType[] StatueTypes { get; }
public virtual bool NoGoodies => false;
@ -45,11 +44,11 @@ namespace Server.Mobiles
public Item GetArtifact()
{
double random = Utility.RandomDouble();
if (0.05 >= random)
if (random <= 0.05)
return CreateArtifact(UniqueList);
if (0.15 >= random)
if (random <= 0.15)
return CreateArtifact(SharedList);
if (0.30 >= random)
if (random <= 0.30)
return CreateArtifact(DecorativeList);
return null;
@ -80,9 +79,9 @@ namespace Server.Mobiles
int level;
double random = Utility.RandomDouble();
if (0.05 >= random)
if (random <= 0.05)
level = 20;
else if (0.4 >= random)
else if (random <= 0.4)
level = 15;
else
level = 10;
@ -127,7 +126,7 @@ namespace Server.Mobiles
else
m.SendLocalizedMessage(1054030); // You have gained in Valor!
//No delay on Valor gains
// No delay on Valor gains
}
}
@ -152,7 +151,7 @@ namespace Server.Mobiles
public static void GivePowerScrollTo(Mobile m, PowerScroll ps)
{
if (ps == null || m == null) //sanity
if (ps == null || m == null) // sanity
return;
m.SendLocalizedMessage(1049524); // You have received a scroll of power!
@ -221,13 +220,13 @@ namespace Server.Mobiles
if (map != null)
for (int x = -12; x <= 12; ++x)
for (int y = -12; y <= 12; ++y)
{
double dist = Math.Sqrt(x * x + y * y);
for (int y = -12; y <= 12; ++y)
{
double dist = Math.Sqrt(x * x + y * y);
if (dist <= 12)
new GoodiesTimer(map, X + x, Y + y).Start();
}
if (dist <= 12)
new GoodiesTimer(map, X + x, Y + y).Start();
}
}
return base.OnBeforeDeath();
@ -237,7 +236,7 @@ namespace Server.Mobiles
{
if (Map == Map.Felucca)
{
//TODO: Confirm SE change or AoS one too?
// TODO: Confirm SE change or AoS one too?
List<DamageStore> rights = GetLootingRights(DamageEntries, HitsMax);
List<Mobile> toGive = new List<Mobile>();
@ -260,8 +259,9 @@ namespace Server.Mobiles
private class GoodiesTimer : Timer
{
private Map m_Map;
private int m_X, m_Y;
private readonly Map m_Map;
private readonly int m_X;
private readonly int m_Y;
public GoodiesTimer(Map map, int x, int y) : base(TimeSpan.FromSeconds(Utility.RandomDouble() * 10.0))
{
@ -290,32 +290,32 @@ namespace Server.Mobiles
g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map);
if (0.5 >= Utility.RandomDouble())
if (Utility.RandomDouble() <= 0.5)
switch (Utility.Random(3))
{
case 0: // Fire column
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x3709, 10, 30, 5052);
Effects.PlaySound(g, g.Map, 0x208);
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x3709, 10, 30, 5052);
Effects.PlaySound(g, g.Map, 0x208);
break;
}
break;
}
case 1: // Explosion
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36BD, 20, 10, 5044);
Effects.PlaySound(g, g.Map, 0x307);
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36BD, 20, 10, 5044);
Effects.PlaySound(g, g.Map, 0x307);
break;
}
break;
}
case 2: // Ball of fire
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36FE, 10, 10, 5052);
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36FE, 10, 10, 5052);
break;
}
break;
}
}
}
}

View file

@ -91,10 +91,10 @@ namespace Server.Mobiles
{
}
public abstract int Keyword{ get; }
public abstract BaseShield Shield{ get; }
public abstract int SignupNumber{ get; }
public abstract GuildType Type{ get; }
public abstract int Keyword { get; }
public abstract BaseShield Shield { get; }
public abstract int SignupNumber { get; }
public abstract GuildType Type { get; }
public override bool HandlesOnSpeech(Mobile from)
{
@ -123,7 +123,7 @@ namespace Server.Mobiles
Item twoHanded = from.FindItemOnLayer(Layer.TwoHanded);
if (pack?.FindItemByType(shield.GetType()) != null ||
twoHanded != null && shield.GetType().IsInstanceOfType(twoHanded))
(twoHanded != null && shield.GetType().IsInstanceOfType(twoHanded)))
{
Say(1007110); // Why dost thou ask about virtue guards when thou art one?
shield.Delete();

View file

@ -128,7 +128,7 @@ namespace Server.Mobiles
private class AutokillTimer : Timer
{
private Dummy m_Owner;
private readonly Dummy m_Owner;
public AutokillTimer(Dummy owner) : base(TimeSpan.FromMinutes(5.0))
{

View file

@ -8,7 +8,7 @@ namespace Server.Mobiles
{
public class Harrower : BaseCreature
{
private static SpawnEntry[] m_Entries =
private static readonly SpawnEntry[] m_Entries =
{
new SpawnEntry(new Point3D(5242, 945, -40), new Point3D(1176, 2638, 0)), // Destard
new SpawnEntry(new Point3D(5225, 798, 0), new Point3D(1176, 2638, 0)), // Destard
@ -93,7 +93,7 @@ namespace Server.Mobiles
public Type[] SharedList => new[] { typeof(TheRobeOfBritanniaAri) };
public Type[] DecorativeList => new[] { typeof(EvilIdolSkull), typeof(SkullPole) };
public static List<Harrower> Instances{ get; } = new List<Harrower>();
public static List<Harrower> Instances { get; } = new List<Harrower>();
public static bool CanSpawn => Instances.Count == 0;
@ -219,16 +219,16 @@ namespace Server.Mobiles
switch (version)
{
case 0:
{
m_TrueForm = reader.ReadBool();
m_GateItem = reader.ReadItem();
m_Tentacles = reader.ReadStrongMobileList<HarrowerTentacles>();
{
m_TrueForm = reader.ReadBool();
m_GateItem = reader.ReadItem();
m_Tentacles = reader.ReadStrongMobileList<HarrowerTentacles>();
m_Timer = new TeleportTimer(this);
m_Timer.Start();
m_Timer = new TeleportTimer(this);
m_Timer.Start();
break;
}
break;
}
}
}
@ -262,13 +262,13 @@ namespace Server.Mobiles
int level;
double random = Utility.RandomDouble();
if (0.1 >= random)
if (random <= 0.1)
level = 25;
else if (0.25 >= random)
else if (random <= 0.25)
level = 20;
else if (0.45 >= random)
else if (random <= 0.45)
level = 15;
else if (0.70 >= random)
else if (random <= 0.70)
level = 10;
else
level = 5;
@ -326,13 +326,13 @@ namespace Server.Mobiles
if (map != null)
for (int x = -16; x <= 16; ++x)
for (int y = -16; y <= 16; ++y)
{
double dist = Math.Sqrt(x * x + y * y);
for (int y = -16; y <= 16; ++y)
{
double dist = Math.Sqrt(x * x + y * y);
if (dist <= 16)
new GoodiesTimer(map, X + x, Y + y).Start();
}
if (dist <= 16)
new GoodiesTimer(map, X + x, Y + y).Start();
}
m_DamageEntries = new Dictionary<Mobile, int>();
@ -437,18 +437,18 @@ namespace Server.Mobiles
1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
}
public bool IsEligible(Mobile m, Item Artifact) =>
public bool IsEligible(Mobile m, Item artifact) =>
m.Player && m.Alive && m.InRange(Location, 32) &&
m.Backpack?.CheckHold(m, Artifact, false) == true;
m.Backpack?.CheckHold(m, artifact, false) == true;
public Item GetArtifact()
{
double random = Utility.RandomDouble();
if (0.05 >= random)
if (random <= 0.05)
return CreateArtifact(UniqueList);
if (0.15 >= random)
if (random <= 0.15)
return CreateArtifact(SharedList);
if (0.30 >= random)
if (random <= 0.30)
return CreateArtifact(DecorativeList);
return null;
@ -468,8 +468,8 @@ namespace Server.Mobiles
private class SpawnEntry
{
public Point3D m_Entrance;
public Point3D m_Location;
public readonly Point3D m_Entrance;
public readonly Point3D m_Location;
public SpawnEntry(Point3D loc, Point3D ent)
{
@ -480,7 +480,7 @@ namespace Server.Mobiles
private class TeleportTimer : Timer
{
private static int[] m_Offsets =
private static readonly int[] m_Offsets =
{
-1, -1,
-1, 0,
@ -492,7 +492,7 @@ namespace Server.Mobiles
1, 1
};
private Mobile m_Owner;
private readonly Mobile m_Owner;
public TeleportTimer(Mobile owner) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0))
{
@ -514,7 +514,7 @@ namespace Server.Mobiles
if (map == null)
return;
if (0.25 < Utility.RandomDouble())
if (Utility.RandomDouble() > 0.25)
return;
Mobile toTeleport = m_Owner.GetMobilesInRange(16)
@ -571,8 +571,9 @@ namespace Server.Mobiles
private class GoodiesTimer : Timer
{
private Map m_Map;
private int m_X, m_Y;
private readonly Map m_Map;
private readonly int m_X;
private readonly int m_Y;
public GoodiesTimer(Map map, int x, int y) : base(TimeSpan.FromSeconds(Utility.RandomDouble() * 10.0))
{
@ -603,32 +604,32 @@ namespace Server.Mobiles
g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map);
if (0.5 >= Utility.RandomDouble())
if (Utility.RandomDouble() <= 0.5)
switch (Utility.Random(3))
{
case 0: // Fire column
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x3709, 10, 30, 5052);
Effects.PlaySound(g, g.Map, 0x208);
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x3709, 10, 30, 5052);
Effects.PlaySound(g, g.Map, 0x208);
break;
}
break;
}
case 1: // Explosion
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36BD, 20, 10, 5044);
Effects.PlaySound(g, g.Map, 0x307);
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36BD, 20, 10, 5044);
Effects.PlaySound(g, g.Map, 0x307);
break;
}
break;
}
case 2: // Ball of fire
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36FE, 10, 10, 5052);
{
Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration),
0x36FE, 10, 10, 5052);
break;
}
break;
}
}
}
}

View file

@ -7,8 +7,7 @@ namespace Server.Mobiles
private DrainTimer m_Timer;
[Constructible]
public HarrowerTentacles(Mobile harrower = null) :
base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
public HarrowerTentacles(Mobile harrower = null) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
{
Harrower = harrower;
Body = 129;
@ -58,7 +57,7 @@ namespace Server.Mobiles
public override string CorpseName => "a tentacles corpse";
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Harrower{ get; set; }
public Mobile Harrower { get; set; }
public override string DefaultName => "tentacles of the harrower";
@ -107,14 +106,14 @@ namespace Server.Mobiles
switch (version)
{
case 0:
{
Harrower = reader.ReadMobile();
{
Harrower = reader.ReadMobile();
m_Timer = new DrainTimer(this);
m_Timer.Start();
m_Timer = new DrainTimer(this);
m_Timer.Start();
break;
}
break;
}
}
}
@ -128,7 +127,7 @@ namespace Server.Mobiles
private class DrainTimer : Timer
{
private HarrowerTentacles m_Owner;
private readonly HarrowerTentacles m_Owner;
public DrainTimer(HarrowerTentacles owner) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0))
{
@ -148,7 +147,7 @@ namespace Server.Mobiles
foreach (Mobile m in eable)
{
if (m == m_Owner || !(m_Owner.CanBeHarmful(m) || m.Player && m.Alive))
if (m == m_Owner || !(m_Owner.CanBeHarmful(m) || (m.Player && m.Alive)))
continue;
if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != m_Owner.Team))

View file

@ -145,7 +145,7 @@ namespace Server.Mobiles
{
scalar *= 0.1;
if (0.1 >= Utility.RandomDouble())
if (Utility.RandomDouble() <= 0.1)
SpawnPixies(caster);
}
}
@ -165,7 +165,7 @@ namespace Server.Mobiles
CheckQueen();
if (m_Queen != null && 0.1 >= Utility.RandomDouble())
if (m_Queen != null && Utility.RandomDouble() <= 0.1)
SpawnPixies(attacker);
attacker.Damage(Utility.Random(20, 10), this);
@ -192,12 +192,12 @@ namespace Server.Mobiles
switch (version)
{
case 0:
{
m_Queen = reader.ReadMobile<BaseCreature>();
m_SpawnedQueen = reader.ReadBool();
{
m_Queen = reader.ReadMobile<BaseCreature>();
m_SpawnedQueen = reader.ReadBool();
break;
}
break;
}
}
}
}

View file

@ -61,7 +61,7 @@ namespace Server.Mobiles
AddItem(weapon);
//new SkeletalMount().Rider = this;
// new SkeletalMount().Rider = this;
AddItem(new VirtualMountItem(this));
}
@ -142,7 +142,7 @@ namespace Server.Mobiles
{
base.OnGaveMeleeAttack(defender);
if (0.1 >= Utility.RandomDouble()) // 10% chance to drop or throw an unholy bone
if (Utility.RandomDouble() <= 0.1) // 10% chance to drop or throw an unholy bone
AddUnholyBone(defender, 0.25);
CheckSpeedBoost();
@ -152,7 +152,7 @@ namespace Server.Mobiles
{
base.OnGotMeleeAttack(attacker);
if (0.1 >= Utility.RandomDouble()) // 10% chance to drop or throw an unholy bone
if (Utility.RandomDouble() <= 0.1) // 10% chance to drop or throw an unholy bone
AddUnholyBone(attacker, 0.25);
}
@ -160,7 +160,7 @@ namespace Server.Mobiles
{
base.AlterDamageScalarFrom(caster, ref scalar);
if (0.1 >= Utility.RandomDouble()) // 10% chance to throw an unholy bone
if (Utility.RandomDouble() <= 0.1) // 10% chance to throw an unholy bone
AddUnholyBone(caster, 1.0);
}
@ -198,16 +198,16 @@ namespace Server.Mobiles
switch (version)
{
case 1:
{
m_SpeedBoost = reader.ReadBool();
break;
}
{
m_SpeedBoost = reader.ReadBool();
break;
}
}
}
private class VirtualMount : IMount
{
private VirtualMountItem m_Item;
private readonly VirtualMountItem m_Item;
public VirtualMount(VirtualMountItem item) => m_Item = item;
@ -224,7 +224,7 @@ namespace Server.Mobiles
private class VirtualMountItem : Item, IMountItem
{
private VirtualMount m_Mount;
private readonly VirtualMount m_Mount;
public VirtualMountItem(Mobile mob)
: base(0x3EBB)
@ -241,7 +241,7 @@ namespace Server.Mobiles
: base(serial) =>
m_Mount = new VirtualMount(this);
public Mobile Rider{ get; private set; }
public Mobile Rider { get; private set; }
public IMount Mount => m_Mount;
@ -269,8 +269,8 @@ namespace Server.Mobiles
private class DelayTimer : Timer
{
private Mobile m_Mobile;
private Mobile m_Target;
private readonly Mobile m_Mobile;
private readonly Mobile m_Target;
public DelayTimer(Mobile m, Mobile target) : base(TimeSpan.FromSeconds(1.0))
{

View file

@ -14,8 +14,8 @@ namespace Server.Mobiles
Map.Ilshenar
};
private static TimeSpan FastRegenRate = TimeSpan.FromSeconds(.5);
private static TimeSpan CPUSaverRate = TimeSpan.FromSeconds(2);
private static readonly TimeSpan FastRegenRate = TimeSpan.FromSeconds(.5);
private static readonly TimeSpan CPUSaverRate = TimeSpan.FromSeconds(2);
public static Type[] Artifacts =
{
@ -191,7 +191,7 @@ namespace Server.Mobiles
private class ParagonStamRegen : Timer
{
private BaseCreature m_Owner;
private readonly BaseCreature m_Owner;
public ParagonStamRegen(Mobile m)
: base(FastRegenRate, FastRegenRate)

View file

@ -83,7 +83,7 @@ namespace Server.Mobiles
{
base.OnGaveMeleeAttack(defender);
if (0.2 >= Utility.RandomDouble())
if (Utility.RandomDouble() <= 0.2)
Earthquake();
}
@ -100,7 +100,7 @@ namespace Server.Mobiles
foreach (Mobile m in eable)
{
if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive))
if (m == this || !(CanBeHarmful(m) || (m.Player && m.Alive)))
continue;
if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team))

View file

@ -90,7 +90,7 @@ namespace Server.Mobiles
foreach (Mobile m in eable)
{
if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive))
if (m == this || !(CanBeHarmful(m) || (m.Player && m.Alive)))
continue;
if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team))
@ -116,7 +116,7 @@ namespace Server.Mobiles
{
base.OnGaveMeleeAttack(defender);
if (0.25 >= Utility.RandomDouble())
if (Utility.RandomDouble() <= 0.25)
DrainLife();
}
@ -124,7 +124,7 @@ namespace Server.Mobiles
{
base.OnGotMeleeAttack(attacker);
if (0.25 >= Utility.RandomDouble())
if (Utility.RandomDouble() <= 0.25)
DrainLife();
}

View file

@ -121,7 +121,7 @@ namespace Server.Mobiles
if (Map == null)
return;
if (!(0.2 > Utility.RandomDouble()))
if (!(Utility.RandomDouble() < 0.2))
return;
Mobile target = null;
@ -150,7 +150,7 @@ namespace Server.Mobiles
foreach (Mobile m in eable)
{
if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive))
if (m == this || !(CanBeHarmful(m) || (m.Player && m.Alive)))
continue;
if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team))

View file

@ -76,7 +76,7 @@ namespace Server.Mobiles
public override void AlterDamageScalarFrom(Mobile caster, ref double scalar)
{
if (0.1 >= Utility.RandomDouble())
if (Utility.RandomDouble() <= 0.1)
SpawnPixies(caster);
}
@ -93,7 +93,7 @@ namespace Server.Mobiles
{
base.OnGotMeleeAttack(attacker);
if (0.1 >= Utility.RandomDouble())
if (Utility.RandomDouble() <= 0.1)
SpawnPixies(attacker);
}

View file

@ -4,7 +4,7 @@ namespace Server.Mobiles
{
public class Wanderer : Mobile
{
private Timer m_Timer;
private readonly Timer m_Timer;
[Constructible]
public Wanderer()
@ -47,7 +47,7 @@ namespace Server.Mobiles
private class InternalTimer : Timer
{
private int m_Count;
private Wanderer m_Owner;
private readonly Wanderer m_Owner;
public InternalTimer(Wanderer owner) : base(TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.1)) => m_Owner = owner;