-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
136 lines (134 loc) · 4.96 KB
/
Program.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
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace cdda_item_creator
{
public static class ObjectExtensions
{
public static T DeepCopy<T>(this T original)
{
return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(original));
}
}
static class Program
{
// the container for the lists of CDDA objects by type
public static class LoadedObjectDictionary
{
static Dictionary<string, HashSet<string>> ids_by_type = new Dictionary<string, HashSet<string>> { };
static Dictionary<string, List<Mtype>> mtypes_by_id = new Dictionary<string, List<Mtype>> { };
static Dictionary<string, List<spell.spell_type>> spells_by_id = new Dictionary<string, List<spell.spell_type>> { };
static Dictionary<string, List<MonsterAttack>> mattacks_by_id = new Dictionary<string, List<MonsterAttack>> { };
static Dictionary<string, List<MaterialType>> materials_by_id = new Dictionary<string, List<MaterialType>> { };
static public void Add(string type, string id)
{
HashSet<string> temp_list;
if(ids_by_type.TryGetValue(type, out temp_list))
{
temp_list.Add(id);
ids_by_type[type] = temp_list;
} else
{
temp_list = new HashSet<string> { id };
ids_by_type.Add(type, temp_list);
}
}
static public void Add(string id, MaterialType material)
{
List<MaterialType> temp_material;
if (materials_by_id.TryGetValue(id, out temp_material))
{
temp_material.Add(material);
materials_by_id[id] = temp_material;
}
else
{
temp_material = new List<MaterialType> { material };
materials_by_id.Add(id, temp_material);
}
}
static public void Add(string id, MonsterAttack mattack)
{
List<MonsterAttack> temp_attack;
if (mattacks_by_id.TryGetValue(id, out temp_attack))
{
temp_attack.Add(mattack);
mattacks_by_id[id] = temp_attack;
} else
{
temp_attack = new List<MonsterAttack> { mattack };
mattacks_by_id.Add(id, temp_attack);
}
}
static public void Add(string id, Mtype mon)
{
List<Mtype> temp_list;
if(mtypes_by_id.TryGetValue(id, out temp_list))
{
temp_list.Add(mon);
mtypes_by_id[id] = temp_list;
} else
{
temp_list = new List<Mtype> { mon };
mtypes_by_id.Add(id, temp_list);
}
}
static public void Add(string id, spell.spell_type spell)
{
List<spell.spell_type> temp_list;
if (spells_by_id.TryGetValue(id, out temp_list))
{
temp_list.Add(spell);
spells_by_id[id] = temp_list;
}
else
{
temp_list = new List<spell.spell_type> { spell };
spells_by_id.Add(id, temp_list);
}
}
static public Dictionary<string, HashSet<string>>.KeyCollection Keys()
{
return ids_by_type.Keys;
}
static public HashSet<string> GetList(string key)
{
HashSet<string> ret;
ids_by_type.TryGetValue(key, out ret);
return ret;
}
static public List<Mtype> GetMtypes(string id)
{
List<Mtype> ret;
mtypes_by_id.TryGetValue(id, out ret);
return ret;
}
static public List<MonsterAttack> GetMAttacks(string id)
{
List<MonsterAttack> ret;
mattacks_by_id.TryGetValue(id, out ret);
return ret;
}
static public List<MaterialType> GetMaterials(string id)
{
List<MaterialType> ret;
materials_by_id.TryGetValue(id, out ret);
return ret;
}
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SelectorForm());
}
}
}