-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathRemnantItem.cs
159 lines (148 loc) · 5.22 KB
/
RemnantItem.cs
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace RemnantSaveManager
{
public class RemnantItem : IEquatable<Object>, IComparable
{
public enum RemnantItemMode
{
Normal,
Hardcore,
Survival
}
private string itemKey;
private string itemType;
private string itemName;
private string itemAltName;
private string ItemKey {
get { return itemKey; }
set
{
try
{
itemKey = value;
itemType = "Uncategorized";
itemName = itemKey.Substring(itemKey.LastIndexOf('/') + 1);
if (itemKey.Contains("/Weapons/"))
{
itemType = "Weapon";
if (itemName.Contains("Mod_")) itemName = itemName.Replace("/Weapons/", "/Mods/");
}
if (itemKey.Contains("/Armor/") || itemKey.Contains("TwistedMask"))
{
itemType = "Armor";
if (itemKey.Contains("TwistedMask"))
{
itemName = "TwistedMask (Head)";
}
else
{
string[] parts = itemName.Split('_');
itemName = parts[2] + " (" + parts[1] + ")";
}
}
if (itemKey.Contains("/Trinkets/") || itemKey.Contains("BrabusPocketWatch")) itemType = "Trinket";
if (itemKey.Contains("/Mods/")) itemType = "Mod";
if (itemKey.Contains("/Traits/")) itemType = "Trait";
if (itemKey.Contains("/Emotes/")) itemType = "Emote";
itemName = itemName.Replace("Weapon_", "").Replace("Root_", "").Replace("Wasteland_", "").Replace("Swamp_", "").Replace("Pan_", "").Replace("Atoll_", "").Replace("Mod_", "").Replace("Trinket_", "").Replace("Trait_", "").Replace("Quest_", "").Replace("Emote_", "").Replace("Rural_", "").Replace("Snow_", "");
if (!itemType.Equals("Armor"))
{
itemName = Regex.Replace(itemName, "([a-z])([A-Z])", "$1 $2");
}
}
catch (Exception ex)
{
Console.WriteLine("Error processing item name: " + ex.Message);
itemName = value;
}
}
}
public string ItemName
{
get
{
if (itemAltName != null) return itemAltName;
return itemName;
}
}
public string ItemType { get { return itemType; } }
public RemnantItemMode ItemMode { get; set; }
public string ItemNotes { get; set; }
public string ItemAltName { get { return itemAltName; } set { itemAltName = value; } }
public RemnantItem(string key)
{
this.ItemKey = key;
this.ItemMode = RemnantItemMode.Normal;
this.ItemNotes = "";
}
public RemnantItem(string key, RemnantItemMode mode)
{
this.ItemKey = key;
this.ItemMode = mode;
this.ItemNotes = "";
}
public string GetKey()
{
return this.itemKey;
}
public override string ToString()
{
return itemType + ": " + ItemName;
}
public override bool Equals(Object obj)
{
//Check for null and compare run-time types.
if ((obj == null))
{
return false;
}
else if (!this.GetType().Equals(obj.GetType()))
{
if (obj.GetType() == typeof(string))
{
return (this.GetKey().Equals(obj));
}
return false;
}
else
{
RemnantItem rItem = (RemnantItem)obj;
return (this.GetKey().Equals(rItem.GetKey()) && this.ItemMode == rItem.ItemMode);
}
}
public override int GetHashCode()
{
return this.itemKey.GetHashCode();
}
public int CompareTo(Object obj)
{
//Check for null and compare run-time types.
if ((obj == null))
{
return 1;
}
else if (!this.GetType().Equals(obj.GetType()))
{
if (obj.GetType() == typeof(string))
{
return (this.GetKey().CompareTo(obj));
}
return this.ToString().CompareTo(obj.ToString());
}
else
{
RemnantItem rItem = (RemnantItem)obj;
if (this.ItemMode != rItem.ItemMode)
{
return this.ItemMode.CompareTo(rItem.ItemMode);
}
return this.itemKey.CompareTo(rItem.GetKey());
}
}
}
}