Example #1
0
        internal static void Add(Mob mb)
        {
            MappedMob mm = new MappedMob(mb.Name, mb.Id, mb.Room.Id, mb.Level, mb.Rage);

            if (!mMobs.Contains(mm) && !mSubmitted.Contains(mm))
            {
                mMobs.Add(mm);
            }
        }
Example #2
0
        public int CompareTo(object other)
        {
            if (other.GetType() != typeof(MappedMob))
            {
                throw new Exception("Invalid mob compare type: " + other.GetType());
            }
            MappedMob mb = (MappedMob)other;

            return(Name.CompareTo(mb.Name));
        }
Example #3
0
        private static void DoBuildMap(bool update)
        {
            Rooms      = new List <MappedRoom>();
            Mobs       = new List <MappedMob>();
            Spawns     = new List <MappedMob>();
            Adventures = new SortedList <string, int>();

            string     map;
            List <int> nbrs;
            string     name;
            int        id;

            string[] tmp;

            //*
            for (int i = 0; i < 2 && Rooms.Count < 1; i++)
            {
                if (!File.Exists("rooms.dat") || update)
                {
                    Download("rooms");
                }
                if ((map = ReadDecrypt("rooms")) == null)
                {
                    continue;
                }

                foreach (string token in map.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (string.IsNullOrEmpty(token.Trim()) || token.StartsWith("#"))
                    {
                        continue;
                    }

                    tmp = token.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (!int.TryParse(tmp[0], out id))
                    {
                        continue;
                    }
                    name = tmp[tmp.Length - 1];
                    nbrs = new List <int>();
                    for (int j = 1; j < tmp.Length - 1; j++)
                    {
                        nbrs.Add(int.Parse(tmp[j]));
                    }
                    if (nbrs.Count < 1)
                    {
                        continue;
                    }
                    Rooms.Add(new MappedRoom(id, name, nbrs));
                }
            }
            Rooms.Sort();
            LinkRooms();
            //*/

            // ------------------

            MappedMob mm;

            string[] parts;
            for (int i = 0; i < 2 && Mobs.Count < 1; i++)
            {
                if (!File.Exists("mobs.dat") || update)
                {
                    Download("mobs");
                }
                if ((map = ReadDecrypt("mobs")) == null)
                {
                    continue;
                }
                foreach (string token in map.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (string.IsNullOrEmpty(token.Trim()) || token.StartsWith("#"))
                    {
                        continue;
                    }
                    parts = token.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length != 5)
                    {
                        // not good input
                        continue;
                    }
                    mm = new MappedMob(parts[0], long.Parse(parts[1]), int.Parse(parts[2]), long.Parse(parts[3]), long.Parse(parts[4]));
                    Mobs.Add(mm);
                }
                i++;
            }
            Mobs.Sort();

            // -----------------

            for (int i = 0; i < 2 && Adventures.Count < 1; i++)
            {
                if (!File.Exists("raids.dat") || update)
                {
                    Download("raids");
                }
                if ((map = ReadDecrypt("raids")) == null)
                {
                    continue;
                }

                foreach (string token in map.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (string.IsNullOrEmpty(token.Trim()) || token.StartsWith("#"))
                    {
                        continue;
                    }
                    int j = token.IndexOf(";");
                    name = token.Substring(0, j);
                    id   = int.Parse(token.Substring(j + 1));
                    Adventures.Add(name, id);
                }
                i++;
            }

            // ------------------
            // Spawns

            for (int i = 0; i < 2 && Spawns.Count < 1; i++)
            {
                if (!File.Exists("spawns.dat") || update)
                {
                    Download("spawns");
                }
                if ((map = ReadDecrypt("spawns")) == null)
                {
                    continue;
                }
                foreach (string token in map.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (string.IsNullOrEmpty(token.Trim()) || token.StartsWith("#"))
                    {
                        continue;
                    }
                    parts = token.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length != 3)
                    {
                        // not good input
                        continue;
                    }
                    mm = new MappedMob(parts[0], -1, int.Parse(parts[2]), long.Parse(parts[1]), -1);
                    Spawns.Add(mm);
                }
                i++;
            }
            Spawns.Sort();
        }