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,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Server.Spells.Bushido

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Items;

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Items;

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Server.Spells.Bushido
@ -103,7 +102,7 @@ namespace Server.Spells.Bushido
public int m_SwingBonus;
public Timer m_Timer;
public HonorableExecutionInfo(Mobile from, List<object> mods) : this(from, 0, mods, true)
public HonorableExecutionInfo(Mobile from, List<object> mods) : this(from, 0, mods, mods != null)
{
}

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Server.Items;
namespace Server.Spells.Bushido
@ -20,46 +21,35 @@ namespace Server.Spells.Bushido
BaseWeapon weapon = attacker.Weapon as BaseWeapon;
List<Mobile> targets = new List<Mobile>();
List<Mobile> targets = attacker.GetMobilesInRange(weapon.MaxRange)
.Where(m => m != defender).Where(m => m.Combatant == attacker).ToList();
foreach (Mobile m in attacker.GetMobilesInRange(weapon.MaxRange))
{
if (m == defender)
continue;
if (m.Combatant != attacker)
continue;
targets.Add(m);
}
if (targets.Count > 0)
{
if (!CheckMana(attacker, true))
return;
Mobile target = targets[Utility.Random(targets.Count)];
double damageBonus = attacker.Skills.Bushido.Value / 100.0;
if (!defender.Alive)
damageBonus *= 1.5;
attacker.SendLocalizedMessage(1063171); // You transfer the momentum of your weapon into another enemy!
target.SendLocalizedMessage(1063172); // You were hit by the momentum of a Samurai's weapon!
target.FixedParticles(0x37B9, 1, 4, 0x251D, 0, 0, EffectLayer.Waist);
attacker.PlaySound(0x510);
weapon.OnSwing(attacker, target, damageBonus);
CheckGain(attacker);
}
else
if (targets.Count <= 0)
{
attacker.SendLocalizedMessage(1063123); // There are no valid targets to attack!
return;
}
if (!CheckMana(attacker, true))
return;
Mobile target = targets[Utility.Random(targets.Count)];
double damageBonus = attacker.Skills.Bushido.Value / 100.0;
if (!defender.Alive)
damageBonus *= 1.5;
attacker.SendLocalizedMessage(1063171); // You transfer the momentum of your weapon into another enemy!
target.SendLocalizedMessage(1063172); // You were hit by the momentum of a Samurai's weapon!
target.FixedParticles(0x37B9, 1, 4, 0x251D, 0, 0, EffectLayer.Waist);
attacker.PlaySound(0x510);
weapon.OnSwing(attacker, target, damageBonus);
CheckGain(attacker);
}
public override void CheckGain(Mobile m)
@ -67,4 +57,4 @@ namespace Server.Spells.Bushido
m.CheckSkill(MoveSkill, RequiredSkill, 120.0);
}
}
}
}

View file

@ -27,13 +27,7 @@ namespace Server.Spells.Bushido
public static bool CheckExpansion(Mobile from)
{
if (!(from is PlayerMobile))
return true;
if (from.NetState == null)
return false;
return from.NetState.SupportsExpansion(Expansion.SE);
return (from as PlayerMobile)?.NetState?.SupportsExpansion(Expansion.SE) == true;
}
public override bool CheckCast()
@ -129,4 +123,4 @@ namespace Server.Spells.Bushido
caster.Send(new ToggleSpecialAbility(spellID + 1, false));
}
}
}
}