-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpeciesTable.cs
168 lines (154 loc) · 5.31 KB
/
SpeciesTable.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
160
161
162
163
164
165
166
167
168
using System.Data;
using System.IO;
using System.Reflection;
namespace Furcadia
{
internal class SpeciesTable
{
#region Private Fields
private static DataTable dt = null;
#endregion Private Fields
#region Public Methods
public SpeciesTable()
{
try
{
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Furcadia.Resources.SpeciesTable.csv");
using (StreamReader reader = new StreamReader(stream))
{
string result = reader.ReadToEnd();
result = result.Replace("\r", "");
result = result.Replace("\"", "");
string[] csvRows = result.Split('\n');
string[] fields = null;
dt = new DataTable();
foreach (string Field in csvRows[0].Split(new char[] { ',' }))
dt.Columns.Add(new DataColumn(Field, typeof(string)));
for (int i = 1; i < csvRows.Length; i++)
{
fields = csvRows[i].Split(',');
DataRow row = dt.NewRow();
row.ItemArray = fields;
dt.Rows.Add(row);
}
}
}
catch
{
}
}
/// <summary>
/// Specs the number.
/// </summary>
/// <param name="species">The species.</param>
/// <param name="special">The special.</param>
/// <returns></returns>
public static int SpecNum(int species, int special)
{
int result = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
int.TryParse(dt.Rows[i]["Special"].ToString(), out int Special);
if (Special == special)
{
switch (Special)
{
// Rodent
case 0:
case 10:
case 40:
case 50:
case 80:
case 100:
// Equine
case 1:
case 11:
case 41:
case 51:
case 81:
case 101:
// Feline
case 2:
case 12:
case 42:
case 52:
case 82:
case 102:
// cainine
case 3:
case 13:
case 43:
case 53:
case 83:
case 103:
// Musteline
case 4:
case 14:
case 44:
case 54:
case 84:
case 104:
// Lapine
case 5:
case 15:
case 45:
case 55:
case 85:
case 105:
// Squirrel
case 6:
case 16:
case 46:
case 56:
case 86:
case 106:
// Bovine
case 7:
case 17:
case 47:
case 57:
case 87:
case 107:
// SUrsine
case 8:
case 18:
case 48:
case 58:
case 88:
case 108:
// Squirrel
case 9:
result = species + 1;
break;
default:
int.TryParse(dt.Rows[i]["DS"].ToString(), out result);
break;
}
break;
}
}
return result;
}
/// <summary>
/// Wingses the number.
/// </summary>
/// <param name="species">The species.</param>
/// <param name="special">The special.</param>
/// <returns></returns>
public static int WingsNum(int species, int special)
{
int result = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
int.TryParse(dt.Rows[i]["Special"].ToString(), out int Special);
if (Special == special)
{
if (int.TryParse(dt.Rows[i]["Wings"].ToString(), out result))
break;
}
}
return result;
}
#endregion Public Methods
}
}