Exemplo n.º 1
0
        /// <summary>
        /// Gets the section name starting from guard and section ids.
        /// </summary>
        /// <param name="guardId">id of the guard</param>
        /// <param name="sectionId">id of the section</param>
        /// <returns>name of the section if found, else "Unknown"</returns>
        public string GetSectionName(uint guardId, uint sectionId)
        {
            var ret = "Unknown";

            try
            {
                MapDatabase.Worlds.ToList().ForEach(w =>
                {
                    if (!w.Value.Guards.TryGetValue(guardId, out var g))
                    {
                        return;
                    }
                    if (!g.Sections.TryGetValue(sectionId, out var s))
                    {
                        return;
                    }
                    var nameId = s.NameId;
                    ret        = RegionsDatabase.GetZoneName(nameId);
                });
            }
            catch
            {
                // ignored
            }
            return(ret);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tries to convert a continent id to a guard name or dungeon name.
        /// </summary>
        /// <param name="continentId">id of the continent</param>
        /// <param name="name">resulting name, "Unknown" if not found</param>
        /// <returns>true if value was successfully found</returns>
        public bool TryGetGuardOrDungeonNameFromContinentId(uint continentId, out string name)
        {
            if (DungeonDatabase.Dungeons.TryGetValue(continentId, out var dung))
            {
                name = dung.Name;
                return(true);
            }
            var guard = MapDatabase.Worlds[1].Guards.FirstOrDefault(x => x.Value.ContinentId == continentId);

            if (guard.Value == null)
            {
                name = "Unknown";
                return(false);
            }
            name = RegionsDatabase.GetZoneName(guard.Value.NameId);
            return(true);
        }
 /// <summary>
 /// Tries to convert a continent id to a guard name or dungeon name.
 /// </summary>
 /// <param name="continentId">id of the continent</param>
 /// <param name="name">resulting name, "Unknown" if not found</param>
 /// <returns>true if value was successfully found</returns>
 public bool TryGetGuardOrDungeonNameFromContinentId(uint continentId, out string name)
 {
     if (DungeonDatabase.Dungeons.TryGetValue(continentId, out var dung))
     {
         name = dung.Name;
         return(true);
     }
     var(_, guard) = MapDatabase.Worlds[1].Guards.FirstOrDefault(x => x.Value.ContinentId == continentId);
     // ReSharper disable once ConditionIsAlwaysTrueOrFalse
     if (guard == null)
     {
         name = "Unknown";
         return(false);
     }
     name = RegionsDatabase.GetZoneName(guard.NameId);
     return(true);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the guard name for the specified dungeon.
        /// </summary>
        /// <param name="dungeonId">id of the dungeon</param>
        /// <returns>guard name of the dungeon if found, else "Unknown"</returns>
        public string GetDungeonGuardName(uint dungeonId)
        {
            var ret       = "Unknown";
            var dungWorld = MapDatabase.Worlds[9999];
            var guardList = dungWorld.Guards.Values.ToList();
            var guard     = guardList.FirstOrDefault(x => x.Sections.ContainsKey(dungeonId));

            if (guard == null)
            {
                return(ret);
            }

            var openWorld = MapDatabase.Worlds[1];

            if (!openWorld.Guards.TryGetValue(guard.Id, out var grd))
            {
                return(ret);
            }

            ret = RegionsDatabase.GetZoneName(grd.NameId);
            return(ret);
        }