-
Notifications
You must be signed in to change notification settings - Fork 0
/
RPGArmor.cs
374 lines (352 loc) · 13.2 KB
/
RPGArmor.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace RPG
{
public class RPGArmor: RPGItem
{
#region Enums
public enum ArmorType
{
// corresponds to body slot
Head = 0,
Torso = 2,
Shield = 4,
Belt = 7,
Feet = 8,
}
public enum ArmorClass
{
SmallHelm = 1,
FullHelm = 2,
LeatherArmor = 3,
ChainArmor = 4,
PlateArmor = 5,
Belt = 6,
LightBoots = 7,
HeavyBoots = 8,
RoundShield = 9,
KiteShield = 10,
TowerShield = 11,
}
#endregion
#region public Defs
// default armor bonus
public static int DEF_HELMET_SMALL = 1;
public static int DEF_HELMET_FULL = 2;
public static int DEF_TORSO_LEATHER = 1;
public static int DEF_TORSO_CHAIN = 3;
public static int DEF_TORSO_PLATE = 5;
public static int DEF_BELT = 2;
public static int DEF_BOOTS_LIGHT = 1;
public static int DEF_BOOTS_HEAVY = 2;
public static int DEF_SHIELD_ROUND = 1;
public static int DEF_SHIELD_KITE = 2;
public static int DEF_SHIELD_TOWER = 3;
// default maximum dexterity bonus while wearing
public static int MAXDEX_HELMET_SMALL = 3;
public static int MAXDEX_HELMET_FULL = 2;
public static int MAXDEX_TORSO_LEATHER = 4;
public static int MAXDEX_TORSO_CHAIN = 3;
public static int MAXDEX_TORSO_PLATE = 2;
public static int MAXDEX_BELT = 3;
public static int MAXDEX_BOOTS_LIGHT = 3;
public static int MAXDEX_BOOTS_HEAVY = 2;
public static int MAXDEX_SHIELD_ROUND = 4;
public static int MAXDEX_SHIELD_KITE = 3;
public static int MAXDEX_SHIELD_TOWER = 2;
// defaul max item durability points
public static int MAXDUR_HELMET_SMALL = 200;
public static int MAXDUR_HELMET_FULL = 400;
public static int MAXDUR_TORSO_LEATHER = 300;
public static int MAXDUR_TORSO_CHAIN = 500;
public static int MAXDUR_TORSO_PLATE = 800;
public static int MAXDUR_BELT = 100;
public static int MAXDUR_BOOTS_LIGHT = 100;
public static int MAXDUR_BOOTS_HEAVY = 200;
public static int MAXDUR_SHIELD_ROUND = 400;
public static int MAXDUR_SHIELD_KITE = 600;
public static int MAXDUR_SHIELD_TOWER = 1000;
// default armor values
public static int VALUE_HELMET_SMALL = 25;
public static int VALUE_HELMET_FULL = 50;
public static int VALUE_TORSO_LEATHER = 100;
public static int VALUE_TORSO_CHAIN = 300;
public static int VALUE_TORSO_PLATE = 500;
public static int VALUE_BELT = 50;
public static int VALUE_BOOTS_LIGHT = 35;
public static int VALUE_BOOTS_HEAVY = 75;
public static int VALUE_SHIELD_ROUND = 50;
public static int VALUE_SHIELD_KITE = 150;
public static int VALUE_SHIELD_TOWER = 300;
#endregion
#region Member Declarations
private ArmorClass m_class;
private ArmorType m_type;
private int m_Defense;
private int m_MaxDex;
private int m_DurabilityMax;
private int m_DurabilityCurrent;
#endregion
#region Constructor and Setup
public RPGArmor(ArmorClass a)
{
// set all armor similarities
this.BaseSpeed = 0;
this.Actions = null;
this.Color1 = Color.Gray;
this.Color2 = Color.Black;
this.m_class = a;
this.m_type = GetArmorTypeFromClass(a);
this.Name = GetNameFromArmorClassEnum(a);
this.Slot = GetSlotFromArmorClassEnum(a);
// set piece-specific info
switch (a)
{
case(ArmorClass.Belt):
{
this.m_Defense = DEF_BELT;
this.m_MaxDex = MAXDEX_BELT;
this.m_DurabilityMax = MAXDUR_BELT;
this.ItemValue = VALUE_BELT;
break;
}
case (ArmorClass.SmallHelm):
{
this.m_Defense = DEF_HELMET_SMALL;
this.m_MaxDex = MAXDEX_HELMET_SMALL;
this.m_DurabilityMax = MAXDUR_HELMET_SMALL;
this.ItemValue = VALUE_HELMET_SMALL;
break;
}
case (ArmorClass.FullHelm):
{
this.m_Defense = DEF_HELMET_FULL;
this.m_MaxDex = MAXDEX_HELMET_FULL;
this.m_DurabilityMax = MAXDUR_HELMET_FULL;
this.ItemValue = VALUE_HELMET_FULL;
break;
}
case (ArmorClass.HeavyBoots):
{
this.m_Defense = DEF_BOOTS_HEAVY;
this.m_MaxDex = MAXDEX_BOOTS_HEAVY;
this.m_DurabilityMax = MAXDUR_BOOTS_HEAVY;
this.ItemValue = VALUE_BOOTS_HEAVY;
break;
}
case (ArmorClass.LightBoots):
{
this.m_Defense = DEF_BOOTS_LIGHT;
this.m_MaxDex = MAXDEX_BOOTS_LIGHT;
this.m_DurabilityMax = MAXDUR_BOOTS_LIGHT;
this.ItemValue = VALUE_BOOTS_LIGHT;
break;
}
case (ArmorClass.LeatherArmor):
{
this.m_Defense = DEF_TORSO_LEATHER;
this.m_MaxDex = MAXDEX_TORSO_LEATHER;
this.m_DurabilityMax = MAXDUR_TORSO_LEATHER;
this.ItemValue = VALUE_TORSO_LEATHER;
this.Color1 = Color.Brown;
this.Color2 = Color.Tan;
break;
}
case (ArmorClass.ChainArmor):
{
this.m_Defense = DEF_TORSO_CHAIN;
this.m_MaxDex = MAXDEX_TORSO_CHAIN;
this.m_DurabilityMax = MAXDUR_TORSO_CHAIN;
this.ItemValue = VALUE_TORSO_CHAIN;
this.Color1 = Color.Gray;
this.Color2 = Color.Silver;
break;
}
case (ArmorClass.PlateArmor):
{
this.m_Defense = DEF_TORSO_PLATE;
this.m_MaxDex = MAXDEX_TORSO_PLATE;
this.m_DurabilityMax = MAXDUR_TORSO_PLATE;
this.ItemValue = VALUE_TORSO_PLATE;
break;
}
case (ArmorClass.RoundShield):
{
this.m_Defense = DEF_SHIELD_ROUND;
this.m_MaxDex = MAXDEX_SHIELD_ROUND;
this.m_DurabilityMax = MAXDUR_SHIELD_ROUND;
this.ItemValue = VALUE_SHIELD_ROUND;
break;
}
case (ArmorClass.KiteShield):
{
this.m_Defense = DEF_SHIELD_KITE;
this.m_MaxDex = MAXDEX_SHIELD_KITE;
this.m_DurabilityMax = MAXDUR_SHIELD_KITE;
this.ItemValue = VALUE_SHIELD_KITE;
break;
}
case (ArmorClass.TowerShield):
{
this.m_Defense = DEF_SHIELD_TOWER;
this.m_MaxDex = MAXDEX_SHIELD_TOWER;
this.m_DurabilityMax = MAXDUR_SHIELD_TOWER;
this.ItemValue = VALUE_SHIELD_TOWER;
break;
}
default:
{
break;
}
} // endswitch
// wrap up
ResetDurability();
UpdateDescription();
}
public RPGArmor(ArmorClass a, int ArmorDefense, int MaxDexBonus, int MaxDurability, int Value, string Name)
{
// set all armor similarities
this.BaseSpeed = 0;
this.Actions = null;
this.Color1 = Color.Gray;
this.Color2 = Color.Black;
this.m_class = a;
this.m_type = GetArmorTypeFromClass(a);
this.Name = Name;
this.Slot = GetSlotFromArmorClassEnum(a);
// set specifics
this.m_Defense = ArmorDefense;
this.m_MaxDex = MaxDexBonus;
this.m_DurabilityMax = MaxDurability;
this.ItemValue = Value;
ResetDurability();
UpdateDescription();
}
public override void UpdateDescription()
{
this.m_desc = "" + Defense + " AC, " + "(" + this.Durability + " / " + this.DurabilityMax + ")";
}
#endregion
#region Property methods
public ArmorClass Class
{
get { return m_class; }
}
public ArmorType Type
{
get { return m_type; }
}
public int Defense
{
get { return m_Defense; }
set { m_Defense = value; }
}
public int MaxDeterityBonus
{
get { return m_MaxDex; }
set { m_MaxDex = value; }
}
public int Durability
{
get { return m_DurabilityCurrent; }
set { m_DurabilityCurrent = value; }
}
public int DurabilityMax
{
get { return m_DurabilityMax; }
set { m_DurabilityMax = value; }
}
#endregion
#region Static Methods
public static RPGArmor CreateRandomArmorPiece()
{
int c = new RPGCalc().Roll(Enum.GetValues(typeof(ArmorClass)).Length);
ArmorClass ac = (ArmorClass)Enum.Parse(typeof(ArmorClass), c.ToString());
return new RPGArmor(ac);
}
public static RPGArmor CreateRandomTorsoArmor()
{
int c = new RPGCalc().Roll(3) + 2;
ArmorClass ac = (ArmorClass)Enum.Parse(typeof(ArmorClass), c.ToString());
return new RPGArmor(ac);
}
public static RPGArmor CreateRandomShield()
{
int c = new RPGCalc().Roll(3) + 8;
ArmorClass ac = (ArmorClass)Enum.Parse(typeof(ArmorClass), c.ToString());
return new RPGArmor(ac);
}
#endregion
#region Public Methods
public ArmorType GetArmorTypeFromClass(ArmorClass c)
{
switch (c)
{
case (ArmorClass.Belt):
{
return ArmorType.Belt;
//break;
}
case (ArmorClass.LeatherArmor):
case (ArmorClass.ChainArmor):
case (ArmorClass.PlateArmor):
{
return ArmorType.Torso;
//break;
}
case (ArmorClass.SmallHelm):
case (ArmorClass.FullHelm):
{
return ArmorType.Head;
//break;
}
case (ArmorClass.LightBoots):
case (ArmorClass.HeavyBoots):
{
return ArmorType.Feet;
//break;
}
case (ArmorClass.RoundShield):
case (ArmorClass.KiteShield):
case (ArmorClass.TowerShield):
{
return ArmorType.Shield;
//break;
}
default:
{
return ArmorType.Torso;
//break;
}
}
}
public void ResetDurability()
{
m_DurabilityCurrent = m_DurabilityMax;
}
public static string GetNameFromArmorClassEnum(ArmorClass ac)
{
string name = Enum.GetName(typeof(ArmorClass), ac);
// often the name has two words, with midCaps involved.
for (int i = 1; i < name.Length; i++) // start at 1 because it always starts with a cap
{
// if caps
if (name[i].ToString() != name[i].ToString().ToLower())
{
// then insert a space before this index.
name = name.Insert(i, " ");
break;
}
}
return name;
}
public Inventory.BodySlot GetSlotFromArmorClassEnum(ArmorClass ac)
{
// since we specifically wrote the armor type values to match the slots, we're set.
return (Inventory.BodySlot)Enum.Parse(typeof(Inventory.BodySlot), ((int)GetArmorTypeFromClass(ac)).ToString());
}
#endregion
}
}