#region Arthea License
/***********************************************************************
* Arthea MUD by R. Jennings (2007) http://arthea.googlecode.com/ *
* By using this code you comply with the Artistic and GPLv2 Licenses. *
***********************************************************************/
#endregion
namespace Arthea.Affects
{
/// <summary>
/// Implements an Affect
/// </summary>
public class Affect
{
#region [rgn] Fields (2)
private int duration;
private AffectFlags flag;
#endregion [rgn]
#region [rgn] Constructors (2)
/// <summary>
/// Initializes a new instance of the <see cref="Affect"/> class.
/// </summary>
/// <param name="flag">The flag.</param>
/// <param name="duration">The duration.</param>
public Affect(AffectFlags flag, int duration)
{
this.flag = flag;
this.duration = duration;
}
/// <summary>
/// Initializes a new instance of the <see cref="Affect"/> class.
/// </summary>
public Affect()
{
duration = -1;
}
#endregion [rgn]
#region [rgn] Properties (2)
/// <summary>
/// Gets or sets the duration.
/// </summary>
/// <value>The duration.</value>
public int Duration
{
get { return duration; }
set { duration = value; }
}
/// <summary>
/// Gets or sets the flags.
/// </summary>
/// <value>The flags.</value>
public AffectFlags Flag
{
get { return flag; }
set { flag = value; }
}
#endregion [rgn]
#region [rgn] Methods (2)
// [rgn] Public Methods (2)
/// <summary>
/// Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
/// </summary>
/// <param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>.</param>
/// <returns>
/// true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
/// </returns>
public override bool Equals(object obj)
{
Affect a = obj as Affect;
if ((object) a == null)
{
return false;
}
return base.Equals(obj) && flag == a.flag;
}
/// <summary>
/// Serves as a hash function for a particular type. <see cref="M:System.Object.GetHashCode"></see> is suitable for use in hashing algorithms and data structures like a hash table.
/// </summary>
/// <returns>
/// A hash code for the current <see cref="T:System.Object"></see>.
/// </returns>
public override int GetHashCode()
{
return flag.GetHashCode();
}
#endregion [rgn]
#region Operator Overloads
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="aff1">The aff1.</param>
/// <param name="aff2">The aff2.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(Affect aff1, Affect aff2)
{
if (ReferenceEquals(aff1, aff2))
return true;
if (aff1 == null || aff2 == null)
return false;
return (aff1.Flag == aff2.Flag);
}
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="aff1">The aff1.</param>
/// <param name="aff2">The aff2.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(Affect aff1, Affect aff2)
{
return !(aff1 == aff2);
}
#endregion
}
}