Пример #1
0
        public void LoadEliteDrops()
        {
            try
            {
                EliteDrops.Clear();
                var pathArray = Directory.GetFiles(Settings.DropPath + @".\Elites\", Name + ".txt", SearchOption.TopDirectoryOnly);

                string path = string.Empty;
                if (pathArray.Length > 0)
                {
                    path = pathArray[0];
                }

                if (!File.Exists(path))
                {
                    //  Create a dummy/empty

                    return;
                }

                string[] lines = File.ReadAllLines(path);

                for (int i = 0; i < lines.Length; i++)
                {
                    if (lines[i].StartsWith(";") || string.IsNullOrWhiteSpace(lines[i]))
                    {
                        continue;
                    }

                    EliteDropInfo drop = EliteDropInfo.FromLine(lines[i], Name);
                    if (drop == null)
                    {
                        SMain.Enqueue(string.Format("Could not load Drop: {0}, Line {1}", Name, lines[i]));
                        continue;
                    }

                    EliteDrops.Add(drop);
                }
            }
            catch (Exception ex)
            {
                SMain.Enqueue(ex);
            }
        }
Пример #2
0
        public static EliteDropInfo FromLine(string s, string mobsName = "")
        {
            string[] parts = s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            //for (int i = 0; i < parts.Length; i++)  // Mob Drop Debug Code
            //    SMain.Enqueue(parts[i] + " " + mobsName);
            EliteDropInfo info = new EliteDropInfo();

            if (!int.TryParse(parts[0].Substring(2), out info.Chance))
            {
                return(null);
            }
            if (string.Compare(parts[1], "Gold", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (parts.Length < 4)
                {
                    return(null);
                }
                if (!uint.TryParse(parts[2], out info.Gold) || info.Gold == 0)
                {
                    return(null);
                }
                switch (parts[3])
                {
                case "LV1":
                    info.EliteLevel = 1;
                    break;

                case "LV2":
                    info.EliteLevel = 2;
                    break;

                case "LV3":
                    info.EliteLevel = 3;
                    break;

                case "LV4":
                    info.EliteLevel = 4;
                    break;

                case "LV5":
                    info.EliteLevel = 5;
                    break;

                case "LV6":
                    info.EliteLevel = 6;
                    break;

                case "LV7":
                    info.EliteLevel = 7;
                    break;

                case "LV8":
                    info.EliteLevel = 8;
                    break;
                }
            }
            else
            {
                info.Item = SMain.Envir.GetItemInfo(parts[1]);
                if (info.Item == null)
                {
                    return(null);
                }

                if (parts.Length > 2)
                {
                    string dropRequirement = parts[2];
                    if (dropRequirement.ToUpper() == "Q")
                    {
                        info.QuestRequired = true;
                    }
                    else
                    {
                        switch (dropRequirement)
                        {
                        case "LV1":
                            info.EliteLevel = 1;
                            break;

                        case "LV2":
                            info.EliteLevel = 2;
                            break;

                        case "LV3":
                            info.EliteLevel = 3;
                            break;

                        case "LV4":
                            info.EliteLevel = 4;
                            break;

                        case "LV5":
                            info.EliteLevel = 5;
                            break;

                        case "LV6":
                            info.EliteLevel = 6;
                            break;

                        case "LV7":
                            info.EliteLevel = 7;
                            break;

                        case "LV8":
                            info.EliteLevel = 8;
                            break;
                        }
                    }
                }
            }

            return(info);
        }