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

@ -11,7 +11,7 @@ namespace Server.Factions
{
private const int ListenRange = 12;
private static Type[] m_StrongPotions =
private static readonly Type[] m_StrongPotions =
{
typeof(GreaterHealPotion), typeof(GreaterHealPotion), typeof(GreaterHealPotion),
typeof(GreaterCurePotion), typeof(GreaterCurePotion), typeof(GreaterCurePotion),
@ -21,7 +21,7 @@ namespace Server.Factions
typeof(GreaterExplosionPotion)
};
private static Type[] m_WeakPotions =
private static readonly Type[] m_WeakPotions =
{
typeof(HealPotion), typeof(HealPotion), typeof(HealPotion),
typeof(CurePotion), typeof(CurePotion), typeof(CurePotion),
@ -62,7 +62,7 @@ namespace Server.Factions
}
}
public Orders Orders{ get; private set; }
public Orders Orders { get; private set; }
[CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)]
public Town Town
@ -76,7 +76,7 @@ namespace Server.Factions
}
}
public abstract GuardAI GuardAI{ get; }
public abstract GuardAI GuardAI { get; }
protected override BaseAI ForcedAI => new FactionGuardAI(this);
@ -443,7 +443,7 @@ namespace Server.Factions
public class VirtualMount : IMount
{
private VirtualMountItem m_Item;
private readonly VirtualMountItem m_Item;
public VirtualMount(VirtualMountItem item) => m_Item = item;
@ -460,7 +460,7 @@ namespace Server.Factions
public class VirtualMountItem : Item, IMountItem
{
private VirtualMount m_Mount;
private readonly VirtualMount m_Mount;
public VirtualMountItem(Mobile mob) : base(0x3EA0)
{
@ -472,7 +472,7 @@ namespace Server.Factions
public VirtualMountItem(Serial serial) : base(serial) => m_Mount = new VirtualMount(this);
public Mobile Rider{ get; private set; }
public Mobile Rider { get; private set; }
public IMount Mount => m_Mount;

View file

@ -39,11 +39,11 @@ namespace Server.Factions
Hold = hold;
}
public Type Spell{ get; }
public Type Spell { get; }
public TimeSpan Hold{ get; }
public TimeSpan Hold { get; }
public int Chance{ get; }
public int Chance { get; }
}
public class SpellCombo
@ -52,8 +52,7 @@ namespace Server.Factions
new ComboEntry(typeof(ParalyzeSpell), 20),
new ComboEntry(typeof(ExplosionSpell), 100, TimeSpan.FromSeconds(2.8)),
new ComboEntry(typeof(PoisonSpell), 30),
new ComboEntry(typeof(EnergyBoltSpell))
);
new ComboEntry(typeof(EnergyBoltSpell)));
public static readonly SpellCombo Strong = new SpellCombo(90,
new ComboEntry(typeof(ParalyzeSpell), 20),
@ -62,8 +61,7 @@ namespace Server.Factions
new ComboEntry(typeof(ExplosionSpell), 100, TimeSpan.FromSeconds(2.8)),
new ComboEntry(typeof(EnergyBoltSpell)),
new ComboEntry(typeof(PoisonSpell), 30),
new ComboEntry(typeof(EnergyBoltSpell))
);
new ComboEntry(typeof(EnergyBoltSpell)));
public SpellCombo(int mana, params ComboEntry[] entries)
{
@ -71,9 +69,9 @@ namespace Server.Factions
Entries = entries;
}
public int Mana{ get; }
public int Mana { get; }
public ComboEntry[] Entries{ get; }
public ComboEntry[] Entries { get; }
public static Spell Process(Mobile mob, Mobile targ, ref SpellCombo combo, ref int index, ref DateTime releaseTime)
{
@ -106,7 +104,7 @@ namespace Server.Factions
private SpellCombo m_Combo;
private int m_ComboIndex = -1;
private BaseFactionGuard m_Guard;
private readonly BaseFactionGuard m_Guard;
private DateTime m_ReleaseTarget;
public FactionGuardAI(BaseFactionGuard guard) : base(guard) => m_Guard = guard;
@ -344,11 +342,11 @@ namespace Server.Factions
public void RunTo(Mobile m)
{
/*if ( m.Paralyzed || m.Frozen )
/*if (m.Paralyzed || m.Frozen)
{
if ( m_Mobile.InRange( m, 1 ) )
if (m_Mobile.InRange( m, 1 ))
RunFrom( m );
else if ( !m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 ) )
else if (!m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 ))
OnFailedMove();
}
else
@ -373,9 +371,9 @@ namespace Server.Factions
public void OnFailedMove()
{
/*if ( !m_Mobile.DisallowAllMoves && 20 > Utility.Random( 100 ) && IsAllowed( GuardAI.Magic ) )
/*if (!m_Mobile.DisallowAllMoves && 20 > Utility.Random( 100 ) && IsAllowed( GuardAI.Magic ))
{
if ( m_Mobile.Target != null )
if (m_Mobile.Target != null)
m_Mobile.Target.Cancel( m_Mobile, TargetCancelType.Canceled );
new TeleportSpell( m_Mobile, null ).Cast();
@ -590,7 +588,7 @@ namespace Server.Factions
else if (dispelTarget != null &&
(IsAllowed(GuardAI.Magic) || IsAllowed(GuardAI.Bless) || IsAllowed(GuardAI.Curse)))
{
if (!dispelTarget.Paralyzed && m_Guard.Mana > ManaReserve + 20 && 40 > Utility.Random(100))
if (!dispelTarget.Paralyzed && m_Guard.Mana > ManaReserve + 20 && Utility.Random(100) < 40)
spell = new ParalyzeSpell(m_Guard);
else
spell = new DispelSpell(m_Guard);
@ -610,9 +608,9 @@ namespace Server.Factions
m_ComboIndex = -1;
}
}
else if (20 > Utility.Random(100) && IsAllowed(GuardAI.Magic))
else if (Utility.Random(100) < 20 && IsAllowed(GuardAI.Magic))
{
if (80 > Utility.Random(100))
if (Utility.Random(100) < 80)
{
m_Combo = IsAllowed(GuardAI.Smart) ? SpellCombo.Simple : SpellCombo.Strong;
m_ComboIndex = -1;
@ -635,7 +633,7 @@ namespace Server.Factions
}
}
if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= ManaReserve + 10)
if (spell == null && Utility.Random(100) < 2 && m_Guard.Mana >= ManaReserve + 10)
{
int strMod = GetStatMod(m_Guard, StatType.Str);
int dexMod = GetStatMod(m_Guard, StatType.Dex);
@ -668,10 +666,10 @@ namespace Server.Factions
}
}
if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= ManaReserve + 10 &&
if (spell == null && Utility.Random(100) < 2 && m_Guard.Mana >= ManaReserve + 10 &&
IsAllowed(GuardAI.Curse))
{
if (!combatant.Poisoned && 40 > Utility.Random(100))
if (!combatant.Poisoned && Utility.Random(100) < 40)
{
spell = new PoisonSpell(m_Guard);
}

View file

@ -31,18 +31,18 @@ namespace Server.Factions.AI
switch (version)
{
case 0:
{
Faction = Faction.ReadReference(reader);
Type = (ReactionType)reader.ReadEncodedInt();
{
Faction = Faction.ReadReference(reader);
Type = (ReactionType)reader.ReadEncodedInt();
break;
}
break;
}
}
}
public Faction Faction{ get; }
public Faction Faction { get; }
public ReactionType Type{ get; set; }
public ReactionType Type { get; set; }
public void Serialize(IGenericWriter writer)
{
@ -55,7 +55,7 @@ namespace Server.Factions.AI
public class Orders
{
private List<Reaction> m_Reactions;
private readonly List<Reaction> m_Reactions;
public Orders(BaseFactionGuard guard)
{
@ -73,30 +73,30 @@ namespace Server.Factions.AI
switch (version)
{
case 1:
{
Follow = reader.ReadMobile();
goto case 0;
}
{
Follow = reader.ReadMobile();
goto case 0;
}
case 0:
{
int count = reader.ReadEncodedInt();
m_Reactions = new List<Reaction>(count);
{
int count = reader.ReadEncodedInt();
m_Reactions = new List<Reaction>(count);
for (int i = 0; i < count; ++i)
m_Reactions.Add(new Reaction(reader));
for (int i = 0; i < count; ++i)
m_Reactions.Add(new Reaction(reader));
Movement = (MovementType)reader.ReadEncodedInt();
Movement = (MovementType)reader.ReadEncodedInt();
break;
}
break;
}
}
}
public BaseFactionGuard Guard{ get; }
public BaseFactionGuard Guard { get; }
public MovementType Movement{ get; set; }
public MovementType Movement { get; set; }
public Mobile Follow{ get; set; }
public Mobile Follow { get; set; }
public Reaction GetReaction(Faction faction)
{