예제 #1
0
 public DropTable(IniFileSection section)
 {
     foreach (string key in section.GetKeys())
     {
         string name;
         int    num;
         int    max;
         if (key[0] != '*')
         {
             name = key.Substring(key.IndexOf(' ') + 1);
             if (key.IndexOf('-') > 0)
             {
                 string[] array = key.Split()[0].Split('-');
                 num = Convert.ToInt32(array[0]);
                 max = Convert.ToInt32(array[1]);
             }
             else
             {
                 string value = key.Substring(0, key.IndexOf(' '));
                 num = Convert.ToInt32(value);
                 max = num;
             }
         }
         else
         {
             name = key;
             num  = 0;
             max  = 0;
         }
         float chance = Convert.ToSingle(section[key], CultureInfo.InvariantCulture.NumberFormat);
         Drop  value2 = new Drop(num, max, name, chance);
         drops.Add(value2);
     }
     drops.Sort();
 }
예제 #2
0
        private Lucene.Net.Store.Directory getStore(string key)
        {
            IniFileSection store = xIni["STOREDIRECTORY"];

            if (store.elements.Count == 0)
            {
                string s = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                DirectoryPath = System.IO.Path.Combine(s, "AGD");
                if (!System.IO.Directory.Exists(DirectoryPath))
                {
                    System.IO.Directory.CreateDirectory(DirectoryPath);
                }
            }
            else
            {
                string s = store["PATH"];
                DirectoryPath = System.IO.Path.Combine(s, "AGD");
                if (!System.IO.Directory.Exists(DirectoryPath))
                {
                    System.IO.Directory.CreateDirectory(DirectoryPath);
                }
            }

            IniFileSection indexes = xIni["INDEXES"];

            System.Collections.ObjectModel.ReadOnlyCollection <string> keys = indexes.GetKeys();
            bool   found = false;
            string val   = "";

            foreach (string k in keys)
            {
                if (key == k)
                {
                    found = true;
                    val   = indexes[k];
                }
            }

            if (found)
            {
                DirectoryPath = System.IO.Path.Combine(DirectoryPath, val);
                if (!System.IO.Directory.Exists(DirectoryPath))
                {
                    System.IO.Directory.CreateDirectory(DirectoryPath);
                }
            }
            else
            {
                string g = System.Guid.NewGuid().ToString("N");
                indexes[key] = g;
                xIni.Save(inipath);
                DirectoryPath = System.IO.Path.Combine(DirectoryPath, g);
                if (!System.IO.Directory.Exists(DirectoryPath))
                {
                    System.IO.Directory.CreateDirectory(DirectoryPath);
                }
            }

            analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29);
            System.IO.DirectoryInfo    di = new DirectoryInfo(DirectoryPath);
            Lucene.Net.Store.Directory d  = new SimpleFSDirectory(di);
            writer = new IndexWriter(d, analyzer, true, new IndexWriter.MaxFieldLength(255));
            return(writer.GetDirectory());
        }