-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArmourData.cs
78 lines (64 loc) · 2.4 KB
/
ArmourData.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FinalProject
{
internal static class ArmourData
{
public static Dictionary<string, Armour> Armours { get; set; } = new Dictionary<string, Armour>();
static ArmourData()
{
HashSet<string> armourTypes = new HashSet<string>(Enum.GetNames(typeof(Armour.ArmourType)));
StreamReader reader = new StreamReader("../../../Equipment/Armour.txt");
string armourType = "";
List<string> statNames = new List<string>
{
"HP",
"Attack Power",
"Defence",
"Agility",
"Dexterity",
"Critical Rate"
};
do
{
string value = reader.ReadLine();
if (armourTypes.Contains(value))
{
armourType = value;
}
else
{
string name = value;
string description = reader.ReadLine();
int level = int.Parse(reader.ReadLine());
int buyPrice = int.Parse(reader.ReadLine());
int sellPrice = int.Parse(reader.ReadLine());
Dictionary<string, int> modifiers = new Dictionary<string, int>();
foreach (string stat in statNames)
{
string statVal = reader.ReadLine();
modifiers.Add(stat, int.Parse(statVal));
}
Armour.ArmourType type = (Armour.ArmourType)Enum.Parse(typeof(Armour.ArmourType), armourType);
Armour armour = new Armour(name, description, level, buyPrice, sellPrice, modifiers, type);
Armours.Add(name, armour);
}
} while (!reader.EndOfStream);
}
public static Dictionary<string, Armour> GetArmoursOfType(Armour.ArmourType type)
{
Dictionary<string, Armour> armours = new Dictionary<string, Armour>();
foreach ((string name, Armour armour) in Armours)
{
if (armour.Type == type)
{
armours.Add(name, armour);
}
}
return armours;
}
}
}