Beispiel #1
0
        private static SubDb LoadSubDb(string name, string league)
        {
            SubDb subDb = m_LoadedDbs.SingleOrDefault(sDb => sDb.Name.Equals(name) && sDb.League.Equals(league));

            if (subDb != null)
            {
                return(subDb);
            }

            FileInfo currentAssemblyFileInfo = new FileInfo(Assembly.GetEntryAssembly().Location);

            string   dbJson   = null;
            string   dbPath   = Path.Combine(currentAssemblyFileInfo.DirectoryName, DB_FILE_PATH, $"{name}_{league}.ninjadb");
            FileInfo fileInfo = new FileInfo(dbPath);

            if (!Directory.Exists(fileInfo.DirectoryName))
            {
                Directory.CreateDirectory(fileInfo.DirectoryName);
            }
            if (fileInfo.Exists)
            {
                dbJson = File.ReadAllText(fileInfo.FullName, Encoding.UTF8);
            }
            else
            {
                dbJson = GetNinjaJsonData(name, league);
                File.WriteAllText(dbPath, dbJson, Encoding.UTF8);
            }
            dynamic db = JsonConvert.DeserializeObject <ExpandoObject>(dbJson);

            subDb = new SubDb(name, league, db);
            m_LoadedDbs.Add(subDb);

            return(subDb);
        }
Beispiel #2
0
 public static Price CheckItemPrice(Item item, string league)
 {
     if (item.Unique)
     {
         SubDb subDb = LoadSubDb(item.Category, league);
         foreach (dynamic line in subDb.Db.lines)
         {
             if (line.name.Equals(item.Name) && item.MaxLinks >= line.links)
             {
                 return(new Price(line.chaosValue, line.exaltedValue));
             }
         }
     }
     return(new Price(0, 0));
 }
Beispiel #3
0
        private static void SetExaltedValue(string league)
        {
            if (m_ExaltedValue > 0)
            {
                return;
            }

            SubDb subDb = LoadSubDb("currency", league);

            foreach (dynamic line in subDb.Db.lines)
            {
                if (line.currencyTypeName.Equals("Exalted Orb"))
                {
                    m_ExaltedValue = line.receive.value;
                }
            }
        }
Beispiel #4
0
        public static Price CheckItemPrice(DisplayItem item, string league)
        {
            SubDb subDb = LoadSubDb(item.Category, league);

            switch (item.Category)
            {
            case "currency":
            case "fragment":
            {
                SetExaltedValue(league);
                foreach (dynamic line in subDb.Db.lines)
                {
                    if (line.currencyTypeName.Equals(item.Name))
                    {
                        return(new Price(line.receive.value, line.receive.value / m_ExaltedValue));
                    }
                }
                return(new Price(0, 0));
            }
            //case "gems":
            //{


            //}


            //case "maps":
            //{


            //}
            case "essence":
            case "cards":
            {
                foreach (dynamic line in subDb.Db.lines)
                {
                    if (line.name.Equals(item.Name))
                    {
                        return(new Price(line.chaosValue, line.exaltedValue));
                    }
                }
                return(new Price(0, 0));
            }

            case "accessories":
            case "armour":
            case "flasks":
            case "jewels":
            case "weapons":
            {
                if (!item.Unique)
                {
                    return(new Price(0, 0));
                }

                foreach (dynamic line in subDb.Db.lines)
                {
                    if (line.name.Equals(item.Name) && item.MaxLinks >= line.links)
                    {
                        if (string.IsNullOrEmpty(line.variant))
                        {
                            return(new Price(line.chaosValue, line.exaltedValue));
                        }
                        else
                        {
                            string variant = (string)line.variant;
                            int    abyssal = int.Parse(variant.Substring(0, variant.IndexOf(' ')));
                            if (item.AbyssalSockets >= abyssal)
                            {
                                return(new Price(line.chaosValue, line.exaltedValue));
                            }
                        }
                    }
                }
                return(new Price(0, 0));
            }
            }
            return(new Price(0, 0));
        }