From 45e5465a08f9d0376faf58fa4fc44a8c9e248a76 Mon Sep 17 00:00:00 2001 From: Liru Date: Sun, 17 May 2020 23:21:41 +0200 Subject: [PATCH] Add basic point wrapper types (HP, MP, EP, O2P, SP) --- Seraphina/Core/EnergyPoint.cs | 32 ++++++++++++++++++++++++++++++++ Seraphina/Core/HitPoint.cs | 32 ++++++++++++++++++++++++++++++++ Seraphina/Core/ManaPoint.cs | 32 ++++++++++++++++++++++++++++++++ Seraphina/Core/OxygenPoint.cs | 32 ++++++++++++++++++++++++++++++++ Seraphina/Core/SkillPoint.cs | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 Seraphina/Core/EnergyPoint.cs create mode 100644 Seraphina/Core/HitPoint.cs create mode 100644 Seraphina/Core/ManaPoint.cs create mode 100644 Seraphina/Core/OxygenPoint.cs create mode 100644 Seraphina/Core/SkillPoint.cs diff --git a/Seraphina/Core/EnergyPoint.cs b/Seraphina/Core/EnergyPoint.cs new file mode 100644 index 0000000..79d153d --- /dev/null +++ b/Seraphina/Core/EnergyPoint.cs @@ -0,0 +1,32 @@ +using System; + +namespace Seraphina.Core +{ + public struct EnergyPoint : IEquatable, IComparable + { + public int Value { get; set; } + + public EnergyPoint(int v) => Value = v; + + public int CompareTo(EnergyPoint other) => Value.CompareTo(other.Value); + public override bool Equals(object? obj) => obj is EnergyPoint point && Equals(point); + public bool Equals(EnergyPoint other) => Value.Equals(other.Value); + public override int GetHashCode() => Value.GetHashCode(); + public override string ToString() => Value.ToString(); + + #region Operator overloads + + public static implicit operator EnergyPoint(int input) => new EnergyPoint(input); + public static bool operator ==(EnergyPoint left, EnergyPoint right) => left.Equals(right); + public static bool operator !=(EnergyPoint left, EnergyPoint right) => !(left == right); + public static bool operator >(EnergyPoint left, EnergyPoint right) => left.Value > right.Value; + public static bool operator <(EnergyPoint left, EnergyPoint right) => left.Value < right.Value; + public static bool operator >=(EnergyPoint left, EnergyPoint right) => !(left < right); + public static bool operator <=(EnergyPoint left, EnergyPoint right) => !(left > right); + + public static EnergyPoint operator +(EnergyPoint left, EnergyPoint right) => new EnergyPoint(left.Value + right.Value); + public static EnergyPoint operator -(EnergyPoint left, EnergyPoint right) => new EnergyPoint(left.Value - right.Value); + + #endregion + } +} diff --git a/Seraphina/Core/HitPoint.cs b/Seraphina/Core/HitPoint.cs new file mode 100644 index 0000000..dadf88f --- /dev/null +++ b/Seraphina/Core/HitPoint.cs @@ -0,0 +1,32 @@ +using System; + +namespace Seraphina.Core +{ + public struct HitPoint : IEquatable, IComparable + { + public int Value { get; set; } + + public HitPoint(int v) => Value = v; + + public int CompareTo(HitPoint other) => Value.CompareTo(other.Value); + public override bool Equals(object? obj) => obj is HitPoint hp && Equals(hp); + public bool Equals(HitPoint other) => Value.Equals(other.Value); + public override int GetHashCode() => Value.GetHashCode(); + public override string ToString() => Value.ToString(); + + #region Operator overloads + + public static implicit operator HitPoint(int input) => new HitPoint(input); + public static bool operator ==(HitPoint left, HitPoint right) => left.Equals(right); + public static bool operator !=(HitPoint left, HitPoint right) => !(left == right); + public static bool operator >(HitPoint left, HitPoint right) => left.Value > right.Value; + public static bool operator <(HitPoint left, HitPoint right) => left.Value < right.Value; + public static bool operator >=(HitPoint left, HitPoint right) => !(left < right); + public static bool operator <=(HitPoint left, HitPoint right) => !(left > right); + + public static HitPoint operator +(HitPoint left, HitPoint right) => new HitPoint(left.Value + right.Value); + public static HitPoint operator -(HitPoint left, HitPoint right) => new HitPoint(left.Value - right.Value); + + #endregion + } +} diff --git a/Seraphina/Core/ManaPoint.cs b/Seraphina/Core/ManaPoint.cs new file mode 100644 index 0000000..4da63cb --- /dev/null +++ b/Seraphina/Core/ManaPoint.cs @@ -0,0 +1,32 @@ +using System; + +namespace Seraphina.Core +{ + public struct ManaPoint : IEquatable, IComparable + { + public int Value { get; set; } + + public ManaPoint(int v) => Value = v; + + public int CompareTo(ManaPoint other) => Value.CompareTo(other.Value); + public override bool Equals(object? obj) => obj is ManaPoint MP ? Equals(MP) : false; + public bool Equals(ManaPoint other) => Value.Equals(other.Value); + public override int GetHashCode() => Value.GetHashCode(); + public override string ToString() => Value.ToString(); + + #region Operator overloads + + public static implicit operator ManaPoint(int input) => new ManaPoint(input); + public static bool operator ==(ManaPoint left, ManaPoint right) => left.Equals(right); + public static bool operator !=(ManaPoint left, ManaPoint right) => !(left == right); + public static bool operator >(ManaPoint left, ManaPoint right) => left.Value > right.Value; + public static bool operator <(ManaPoint left, ManaPoint right) => left.Value < right.Value; + public static bool operator >=(ManaPoint left, ManaPoint right) => !(left < right); + public static bool operator <=(ManaPoint left, ManaPoint right) => !(left > right); + + public static ManaPoint operator +(ManaPoint left, ManaPoint right) => new ManaPoint(left.Value + right.Value); + public static ManaPoint operator -(ManaPoint left, ManaPoint right) => new ManaPoint(left.Value - right.Value); + + #endregion + } +} diff --git a/Seraphina/Core/OxygenPoint.cs b/Seraphina/Core/OxygenPoint.cs new file mode 100644 index 0000000..0bc0d75 --- /dev/null +++ b/Seraphina/Core/OxygenPoint.cs @@ -0,0 +1,32 @@ +using System; + +namespace Seraphina.Core +{ + public struct OxygenPoint : IEquatable, IComparable + { + public int Value { get; set; } + + public OxygenPoint(int v) => Value = v; + + public int CompareTo(OxygenPoint other) => Value.CompareTo(other.Value); + public override bool Equals(object? obj) => obj is OxygenPoint other && Equals(other); + public bool Equals(OxygenPoint other) => Value.Equals(other.Value); + public override int GetHashCode() => Value.GetHashCode(); + public override string ToString() => Value.ToString(); + + #region Operator overloads + + public static implicit operator OxygenPoint(int input) => new OxygenPoint(input); + public static bool operator ==(OxygenPoint left, OxygenPoint right) => left.Equals(right); + public static bool operator !=(OxygenPoint left, OxygenPoint right) => !(left == right); + public static bool operator >(OxygenPoint left, OxygenPoint right) => left.Value > right.Value; + public static bool operator <(OxygenPoint left, OxygenPoint right) => left.Value < right.Value; + public static bool operator >=(OxygenPoint left, OxygenPoint right) => !(left < right); + public static bool operator <=(OxygenPoint left, OxygenPoint right) => !(left > right); + + public static OxygenPoint operator +(OxygenPoint left, OxygenPoint right) => new OxygenPoint(left.Value + right.Value); + public static OxygenPoint operator -(OxygenPoint left, OxygenPoint right) => new OxygenPoint(left.Value - right.Value); + + #endregion + } +} diff --git a/Seraphina/Core/SkillPoint.cs b/Seraphina/Core/SkillPoint.cs new file mode 100644 index 0000000..24745b8 --- /dev/null +++ b/Seraphina/Core/SkillPoint.cs @@ -0,0 +1,33 @@ +using System; + +namespace Seraphina.Core +{ + public struct SkillPoint : IEquatable, IComparable + { + public int Value { get; } + + public SkillPoint(int v) => Value = v; + + public int CompareTo(SkillPoint other) => Value.CompareTo(other.Value); + public override bool Equals(object? obj) => obj is SkillPoint other && Equals(other); + public bool Equals(SkillPoint other) => Value.Equals(other.Value); + public override int GetHashCode() => Value.GetHashCode(); + public override string ToString() => Value.ToString(); + + #region Operator overloads + + public static implicit operator SkillPoint(int input) => new SkillPoint(input); + public static explicit operator int(SkillPoint input) => input.Value; + public static bool operator ==(SkillPoint left, SkillPoint right) => left.Equals(right); + public static bool operator !=(SkillPoint left, SkillPoint right) => !(left == right); + public static bool operator >(SkillPoint left, SkillPoint right) => left.Value > right.Value; + public static bool operator <(SkillPoint left, SkillPoint right) => left.Value < right.Value; + public static bool operator >=(SkillPoint left, SkillPoint right) => !(left < right); + public static bool operator <=(SkillPoint left, SkillPoint right) => !(left > right); + + public static SkillPoint operator +(SkillPoint left, SkillPoint right) => new SkillPoint(left.Value + right.Value); + public static SkillPoint operator -(SkillPoint left, SkillPoint right) => new SkillPoint(left.Value - right.Value); + + #endregion + } +}