Code cleanup (#188)

This commit is contained in:
Kamron Batman 2020-08-01 08:40:06 -07:00 • committed by GitHub
parent df53c16620
commit 010fd9402a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
185 changed files with 1052 additions and 1271 deletions

View file

@ -88,13 +88,7 @@ namespace Server.Spells.Chivalry
Caster.PlaySound(0x208);
Caster.FixedParticles(0x3709, 1, 30, 9934, 0, 7, EffectLayer.Waist);
int damage = 50 - ComputePowerValue(4);
// TODO: Should caps be applied?
if (damage < 13)
damage = 13;
else if (damage > 55)
damage = 55;
int damage = Math.Clamp(50 - ComputePowerValue(4), 13, 55);
AOS.Damage(Caster, Caster, damage, 0, 100, 0, 0, 0, true);
}

View file

@ -65,7 +65,7 @@ namespace Server.Spells.Chivalry
*/
// TODO: Should caps be applied?
int toHeal = Math.Min(Math.Max(ComputePowerValue(6) + Utility.RandomMinMax(0, 2), 7), 39);
int toHeal = Math.Clamp(ComputePowerValue(6) + Utility.RandomMinMax(0, 2), 7, 39);
if (m.Hits + toHeal > m.HitsMax)
toHeal = m.HitsMax - m.Hits;

View file

@ -66,13 +66,7 @@ namespace Server.Spells.Chivalry
Effects.SendMovingParticles(from, to, itemID, 1, 0, false, false, 33, 3, 9501, 1, 0, EffectLayer.Head,
0x100);
double seconds = ComputePowerValue(20);
// TODO: Should caps be applied?
if (seconds < 3.0)
seconds = 3.0;
else if (seconds > 11.0)
seconds = 11.0;
double seconds = Math.Clamp(ComputePowerValue(20), 3.0, 11.0);
TimeSpan duration = TimeSpan.FromSeconds(seconds);

View file

@ -38,13 +38,7 @@ namespace Server.Spells.Chivalry
m_Table.TryGetValue(Caster, out Timer timer);
timer?.Stop();
int delay = ComputePowerValue(10);
// TODO: Should caps be applied?
if (delay < 7)
delay = 7;
else if (delay > 24)
delay = 24;
int delay = Math.Clamp(ComputePowerValue(10), 7, 24);
m_Table[Caster] = Timer.DelayCall(TimeSpan.FromSeconds(delay), Expire_Callback, Caster);
Caster.Delta(MobileDelta.WeaponDamage);

View file

@ -37,13 +37,7 @@ namespace Server.Spells.Chivalry
m_Table.TryGetValue(Caster, out Timer timer);
timer?.Stop();
double delay = (double)ComputePowerValue(1) / 60;
// TODO: Should caps be applied?
if (delay < 1.5)
delay = 1.5;
else if (delay > 3.5)
delay = 3.5;
double delay = Math.Clamp(ComputePowerValue(1) / 60.0, 1.5, 3.5);
m_Table[Caster] = Timer.DelayCall(TimeSpan.FromMinutes(delay), Expire_Callback, Caster);

View file

@ -45,13 +45,7 @@ namespace Server.Spells.Chivalry
foreach (Mobile m in targets)
{
int damage = ComputePowerValue(10) + Utility.RandomMinMax(0, 2);
// TODO: Should caps be applied?
if (damage < 8)
damage = 8;
else if (damage > 24)
damage = 24;
int damage = Math.Clamp(ComputePowerValue(10) + Utility.RandomMinMax(0, 2), 8, 24);
Caster.DoHarmful(m);
SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 100);

View file

@ -92,13 +92,7 @@ namespace Server.Spells.Chivalry
if (m.Hits < m.HitsMax)
{
int toHeal = ComputePowerValue(10) + Utility.RandomMinMax(0, 2);
// TODO: Should caps be applied?
if (toHeal < 8)
toHeal = 8;
else if (toHeal > 24)
toHeal = 24;
int toHeal = Math.Clamp(ComputePowerValue(10) + Utility.RandomMinMax(0, 2), 8, 24);
Caster.DoBeneficial(m);
m.Heal(toHeal, Caster);