示例#1
0
        public void LoadDrops()
        {
            Drops.Clear();
            string path = Path.Combine(Settings.DropPath, Name + ".txt");

            if (!File.Exists(path))
            {
                string[] contents = new[]
                {
                    ";Pots + Other", string.Empty, string.Empty,
                    ";Weapons", string.Empty, string.Empty,
                    ";Armour", string.Empty, string.Empty,
                    ";Helmets", string.Empty, string.Empty,
                    ";Necklace", string.Empty, string.Empty,
                    ";Bracelets", string.Empty, string.Empty,
                    ";Rings", string.Empty, string.Empty,
                    ";Shoes", string.Empty, string.Empty,
                    ";Belts", string.Empty, string.Empty,
                    ";Stone",
                };

                File.WriteAllLines(path, contents);


                return;
            }

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

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

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

                Drops.Add(drop);
            }

            Drops.Sort((drop1, drop2) =>
            {
                if (drop1.Gold > 0 && drop2.Gold == 0)
                {
                    return(1);
                }
                if (drop1.Gold == 0 && drop2.Gold > 0)
                {
                    return(-1);
                }

                return(drop1.Item.Type.CompareTo(drop2.Item.Type));
            });
        }
示例#2
0
        public void LoadDrops()
        {
            try
            {
                Drops.Clear();
                var pathArray = Directory.GetFiles(Settings.DropPath, Name + ".txt", SearchOption.AllDirectories);

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

                if (!File.Exists(path))
                {
                    return;
                }

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

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

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

                    Drops.Add(drop);
                }

                Drops.Sort((drop1, drop2) =>
                {
                    if (drop1.Gold > 0 && drop2.Gold == 0)
                    {
                        return(1);
                    }
                    if (drop1.Gold == 0 && drop2.Gold > 0)
                    {
                        return(-1);
                    }
                    if (drop1.Gold > 0 && drop2.Gold > 0)
                    {
                        return(drop1.Gold > drop2.Gold ? 1 : -1);
                    }

                    return(drop1.Item.Type.CompareTo(drop2.Item.Type));
                });
            }
            catch (Exception ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#3
0
        private static void ParseGroup(DropInfo parentDrop, string name, List <string> lines, int startLine)
        {
            bool start = false, finish = false;

            var drops = new List <DropInfo>();

            for (int j = startLine; j < lines.Count; j++)
            {
                var line = lines[j].Trim();
                lines[j] = "";

                if (line.Trim() == ("{"))
                {
                    start = true;
                    continue;
                }

                if (line.Trim() == ("}"))
                {
                    finish = true;
                    break;
                }

                if (line.StartsWith(";") || string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                var drop = DropInfo.FromLine(line);

                if (drop == null)
                {
                    MessageQueue.Enqueue(string.Format("Could not load Drop: {0}, Line {1}", name, line));
                    continue;
                }

                if (drop.GroupedDrop != null)
                {
                    ParseGroup(drop, name, lines, j + 1);
                }

                drops.Add(drop);
            }

            if (start && finish)
            {
                parentDrop.GroupedDrop.AddRange(drops);
            }
        }
示例#4
0
        public void LoadDrops()
        {
            for (int i = 0; i < Globals.MaxDragonLevel; i++)
            {
                Drops[i].Clear();
            }
            string path = Path.Combine(Settings.DropPath, "DragonItem.txt");

            if (!File.Exists(path))
            {
                string[] contents = new[]
                {
                    ";Pots + Other", string.Empty, string.Empty,
                    ";Weapons", string.Empty, string.Empty,
                    ";Armour", string.Empty, string.Empty,
                    ";Helmets", string.Empty, string.Empty,
                    ";Necklace", string.Empty, string.Empty,
                    ";Bracelets", string.Empty, string.Empty,
                    ";Rings", string.Empty, string.Empty,
                    ";Shoes", string.Empty, string.Empty,
                    ";Belts", string.Empty, string.Empty,
                    ";Stone",
                };

                File.WriteAllLines(path, contents);


                return;
            }

            string[] lines = File.ReadAllLines(path, Encoding.GetEncoding("euc-kr"));

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

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

                if (drop.level <= 0 || drop.level > Globals.MaxDragonLevel)
                {
                    return;
                }
                Drops[drop.level - 1].Add(drop);
            }

            for (int i = 0; i < Globals.MaxDragonLevel; i++)
            {
                Drops[i].Sort((drop1, drop2) =>
                {
                    if (drop1.Gold > 0 && drop2.Gold == 0)
                    {
                        return(1);
                    }
                    if (drop1.Gold == 0 && drop2.Gold > 0)
                    {
                        return(-1);
                    }

                    return(drop1.Item.Type.CompareTo(drop2.Item.Type));
                });
            }
        }
示例#5
0
        public static void Load(List <DropInfo> list, string name, string path, byte type = 0, bool createIfNotExists = true)
        {
            if (!File.Exists(path))
            {
                if (createIfNotExists)
                {
                    string[] contents = new[]
                    {
                        ";Pots + Other", string.Empty, string.Empty,
                        ";Weapons", string.Empty, string.Empty,
                        ";Armour", string.Empty, string.Empty,
                        ";Helmets", string.Empty, string.Empty,
                        ";Necklace", string.Empty, string.Empty,
                        ";Bracelets", string.Empty, string.Empty,
                        ";Rings", string.Empty, string.Empty,
                        ";Shoes", string.Empty, string.Empty,
                        ";Belts", string.Empty, string.Empty,
                        ";Stone",
                    };

                    File.WriteAllLines(path, contents);
                }

                return;
            }

            var lines = File.ReadAllLines(path).ToList();

            lines = ParseInsert(lines);

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

                DropInfo drop = DropInfo.FromLine(lines[i]);

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

                if (drop.GroupedDrop != null)
                {
                    ParseGroup(drop, name, lines, i + 1);
                }

                drop.Type = type;

                list.Add(drop);
            }

            list.Sort((drop1, drop2) =>
            {
                if (drop1.Gold > 0 && drop2.Gold == 0)
                {
                    return(1);
                }
                if (drop1.Gold == 0 && drop2.Gold > 0)
                {
                    return(-1);
                }

                if (drop1.Item == null || drop2.Item == null)
                {
                    return(0);
                }

                return(drop1.Item.Type.CompareTo(drop2.Item.Type));
            });
        }