Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 • committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Mobiles;
using Server.Targeting;
@ -16,7 +17,7 @@ namespace Server.Spells.Fourth
Reagent.MandrakeRoot
);
public ArchCureSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
public ArchCureSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
{
}
@ -56,15 +57,7 @@ namespace Server.Spells.Fourth
targets.Add(directTarget);
IPooledEnumerable<Mobile> eable = map.GetMobilesInRange(new Point3D(p), 2);
foreach (Mobile m in eable)
{
if (m == directTarget)
continue;
if (AreaCanTarget(m, feluccaRules))
targets.Add(m);
}
targets.AddRange(eable.Where(m => m != directTarget).Where(m => AreaCanTarget(m, feluccaRules)));
eable.Free();
}
@ -180,4 +173,4 @@ namespace Server.Spells.Fourth
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Engines.PartySystem;
using Server.Spells.Second;
using Server.Targeting;
@ -20,7 +21,7 @@ namespace Server.Spells.Fourth
private static Dictionary<Mobile, int> _Table = new Dictionary<Mobile, int>();
public ArchProtectionSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
public ArchProtectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
{
}
@ -43,30 +44,25 @@ namespace Server.Spells.Fourth
SpellHelper.GetSurfaceTop(ref p);
List<Mobile> targets = new List<Mobile>();
if (!Core.AOS)
Effects.PlaySound(p, Caster.Map, 0x299);
Map map = Caster.Map;
if (map != null)
if (Caster.Map == null)
{
IPooledEnumerable<Mobile> eable = map.GetMobilesInRange(new Point3D(p), Core.AOS ? 2 : 3);
foreach (Mobile m in eable)
if (Caster.CanBeBeneficial(m, false))
targets.Add(m);
eable.Free();
FinishSequence();
return;
}
IEnumerable<Mobile> targets = Caster.Map.GetMobilesInRange(new Point3D(p), Core.AOS ? 2 : 3)
.Where(m => Caster.CanBeBeneficial(m, false));
if (Core.AOS)
{
Party party = Party.Get(Caster);
for (int i = 0; i < targets.Count; ++i)
foreach (Mobile m in targets)
{
Mobile m = targets[i];
if (m == Caster || party != null && party.Contains(m))
if (m == Caster || party?.Contains(m) == true)
{
Caster.DoBeneficial(m);
ProtectionSpell.Toggle(Caster, m);
@ -75,27 +71,22 @@ namespace Server.Spells.Fourth
}
else
{
Effects.PlaySound(p, Caster.Map, 0x299);
int val = (int)(Caster.Skills.Magery.Value / 10.0 + 1);
if (targets.Count > 0)
for (int i = 0; i < targets.Count; ++i)
foreach (Mobile m in targets)
{
if (m.BeginAction<ArchProtectionSpell>())
{
Mobile m = targets[i];
Caster.DoBeneficial(m);
m.VirtualArmorMod += val;
if (m.BeginAction<ArchProtectionSpell>())
{
Caster.DoBeneficial(m);
m.VirtualArmorMod += val;
AddEntry(m, val);
new InternalTimer(m, Caster).Start();
AddEntry(m, val);
new InternalTimer(m, Caster).Start();
m.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist);
m.PlaySound(0x1F7);
}
m.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist);
m.PlaySound(0x1F7);
}
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Targeting;
@ -18,7 +17,7 @@ namespace Server.Spells.Fourth
private static HashSet<Mobile> m_UnderEffect = new HashSet<Mobile>();
public CurseSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
public CurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
{
}

View file

@ -19,7 +19,7 @@ namespace Server.Spells.Fourth
Reagent.SulfurousAsh
);
public FireFieldSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
public FireFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
{
}
@ -88,13 +88,8 @@ namespace Server.Spells.Fourth
private DateTime m_End;
private Timer m_Timer;
public FireFieldItem(int itemID, Point3D loc, Mobile caster, Map map, TimeSpan duration, int val)
: this(itemID, loc, caster, map, duration, val, 2)
{
}
public FireFieldItem(int itemID, Point3D loc, Mobile caster, Map map, TimeSpan duration, int val,
int damage) : base(itemID)
int damage = 2) : base(itemID)
{
bool canFit = SpellHelper.AdjustField(ref loc, map, 12, false);
@ -248,7 +243,7 @@ namespace Server.Spells.Fourth
if (map == null || caster == null)
return;
foreach (Mobile m in m_Item.GetMobilesInRange(0))
if (m.Z + 16 > m_Item.Z && m_Item.Z + 12 > m.Z && (!Core.AOS || m != caster) &&
SpellHelper.ValidIndirectTarget(caster, m) && caster.CanBeHarmful(m, false))
@ -303,4 +298,4 @@ namespace Server.Spells.Fourth
}
}
}
}
}

View file

@ -18,7 +18,7 @@ namespace Server.Spells.Fourth
Reagent.SpidersSilk
);
public GreaterHealSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
public GreaterHealSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
{
}
@ -102,4 +102,4 @@ namespace Server.Spells.Fourth
}
}
}
}
}

View file

@ -12,7 +12,7 @@ namespace Server.Spells.Fourth
Reagent.SulfurousAsh
);
public LightningSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
public LightningSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
{
}
@ -86,4 +86,4 @@ namespace Server.Spells.Fourth
}
}
}
}
}

View file

@ -17,7 +17,7 @@ namespace Server.Spells.Fourth
private static HashSet<Mobile> m_Table = new HashSet<Mobile>();
public ManaDrainSpell(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
public ManaDrainSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info)
{
}

View file

@ -24,7 +24,8 @@ namespace Server.Spells.Fourth
private RunebookEntry m_Entry;
public RecallSpell(Mobile caster, Item scroll, RunebookEntry entry = null, Runebook book = null) : base(caster, scroll, m_Info)
public RecallSpell(Mobile caster, RunebookEntry entry = null, Runebook book = null, Item scroll = null) :
base(caster, scroll, m_Info)
{
m_Entry = entry;
m_Book = book;
@ -200,4 +201,4 @@ namespace Server.Spells.Fourth
}
}
}
}
}