Reorganizes Project (#41)

This commit is contained in:
Kamron Batman 2019-08-02 18:13:40 -07:00 committed by GitHub
parent 08bf44af9a
commit 3614a66aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3499 changed files with 79 additions and 55 deletions

View file

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
namespace Server.Items
{
public class HitLower
{
public static readonly TimeSpan AttackEffectDuration = TimeSpan.FromSeconds(10.0);
public static readonly TimeSpan DefenseEffectDuration = TimeSpan.FromSeconds(8.0);
private static HashSet<Mobile> m_AttackTable = new HashSet<Mobile>();
private static HashSet<Mobile> m_DefenseTable = new HashSet<Mobile>();
public static bool IsUnderAttackEffect(Mobile m)
{
return m_AttackTable.Contains(m);
}
public static bool ApplyAttack(Mobile m)
{
if (IsUnderAttackEffect(m))
return false;
m_AttackTable.Add(m);
AttackTimer timer = new AttackTimer(m);
timer.Start();
m.SendLocalizedMessage(1062319); // Your attack chance has been reduced!
return true;
}
private static void RemoveAttack(Mobile m)
{
m_AttackTable.Remove(m);
m.SendLocalizedMessage(1062320); // Your attack chance has returned to normal.
}
public static bool IsUnderDefenseEffect(Mobile m)
{
return m_DefenseTable.Contains(m);
}
public static bool ApplyDefense(Mobile m)
{
if (IsUnderDefenseEffect(m))
return false;
m_DefenseTable.Add(m);
DefenseTimer timer = new DefenseTimer(m);
timer.Start();
m.SendLocalizedMessage(1062318); // Your defense chance has been reduced!
return true;
}
private static void RemoveDefense(Mobile m)
{
m_DefenseTable.Remove(m);
m.SendLocalizedMessage(1062321); // Your defense chance has returned to normal.
}
private class AttackTimer : Timer
{
private Mobile m_Player;
public AttackTimer(Mobile player) : base(AttackEffectDuration)
{
m_Player = player;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()
{
RemoveAttack(m_Player);
}
}
private class DefenseTimer : Timer
{
private Mobile m_Player;
public DefenseTimer(Mobile player) : base(DefenseEffectDuration)
{
m_Player = player;
Priority = TimerPriority.TwoFiftyMS;
}
protected override void OnTick()
{
RemoveDefense(m_Player);
}
}
}
}