1using System.Collections.Generic;
24 public static Dictionary<string, Dictionary<string, Item>>
dict;
30 dict =
new Dictionary<string, Dictionary<string, Item>>();
34 static void AddDir(
string id,
string path)
36 DirectoryInfo directoryInfo =
new DirectoryInfo(path);
37 Dictionary<string, Item> dictionary =
new Dictionary<string, Item>();
38 dict.Add(
id, dictionary);
39 FileInfo[] files = directoryInfo.GetFiles();
40 foreach (FileInfo fileInfo
in files)
42 if (!(fileInfo.Extension !=
".txt"))
44 StreamReader streamReader =
new StreamReader(fileInfo.FullName);
45 string[] array = streamReader.ReadLine().Split(
',');
50 author = ((array.Length >= 2 && !array[1].IsEmpty()) ?
"nameAuthor".lang(array[1]) :
"unknownAuthor".lang()),
51 chance = ((array.Length >= 3) ? array[2].ToInt() : 100),
52 skin = ((array.Length >= 4) ? array[3].ToInt() : 0),
53 id = fileInfo.Name.Replace(fileInfo.Extension,
"")
65 return dict[idCat].Where((KeyValuePair<string, Item> p) => p.Value.chance != 0).ToList().RandomItemWeighted((KeyValuePair<string, Item> p) => p.Value.chance)
72 return dict[idCat].TryGetValue(
id) ??
dict[
"Book"][
"_default"];
static Item GetRandomItem(string idCat="Book")
static Item GetItem(string id, string idCat="Book")
static Dictionary< string, Dictionary< string, Item > > dict