-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathDamageTypes.cs
More file actions
127 lines (101 loc) · 3.48 KB
/
Copy pathDamageTypes.cs
File metadata and controls
127 lines (101 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using MagicalLifeAPI.Properties;
using MonoGUI.MonoLib.CustomTypes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MagicalLifeAPI.Combat
{
public class DamageTypes : Enumeration, IEquatable<DamageTypes>
{
public static readonly DamageTypes Poison = new DamageTypes(1, Lang.Poison);
public static readonly DamageTypes Magic = new DamageTypes(2, Lang.Magic);
public static readonly DamageTypes Fire = new DamageTypes(3, Lang.Fire);
public static readonly DamageTypes Crushing = new DamageTypes(4, Lang.Crushing);
public static readonly DamageTypes Piercing = new DamageTypes(5, Lang.Piercing);
public static readonly ICollection<DamageTypes> List = new List<DamageTypes> { Piercing, Crushing, Fire, Magic, Poison };
protected DamageTypes(int id, string name) : base(id, name)
{
}
/// <summary>
/// Adds the type of the damage.
/// </summary>
/// <param name="damage">The damage.</param>
/// <returns>If the new damage type was registered</returns>
public bool AddDamageType(DamageTypes damage)
{
if(!List.Contains(damage))
{
List.Add(damage);
return true;
}
return false;
}
public override bool Equals(object obj)
{
if (!(obj is DamageTypes))
{
return false;
}
DamageTypes damageTypes = obj as DamageTypes;
return Equals(damageTypes);
}
public override string ToString()
{
return Name;
}
public override int GetHashCode()
{
const int hash = 397;
return hash * Id.GetHashCode() * Name.GetHashCode();
}
public static bool operator ==(DamageTypes left, DamageTypes right)
{
if (left is null)
{
return right is null;
}
return left.Equals(right);
}
public static bool operator !=(DamageTypes left, DamageTypes right)
{
return !(left == right);
}
public static bool operator <(DamageTypes left, DamageTypes right)
{
return left is null ? !(right is null) : left.CompareTo(right) < 0;
}
public static bool operator <=(DamageTypes left, DamageTypes right)
{
return left is null || left.CompareTo(right) <= 0;
}
public static bool operator >(DamageTypes left, DamageTypes right)
{
return !(left is null) && left.CompareTo(right) > 0;
}
public static bool operator >=(DamageTypes left, DamageTypes right)
{
return left is null ? right is null : left.CompareTo(right) >= 0;
}
public static DamageTypes FromString(string roleString)
{
return List.Single(r => string.Equals(r.Name, roleString, StringComparison.OrdinalIgnoreCase));
}
public static DamageTypes FromValue(int value)
{
return List.Single(r => r.Id == value);
}
public bool Equals(DamageTypes other)
{
if (!other.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase))
{
return false;
}
if (other.Id != Id)
{
return false;
}
return true;
}
}
}