コード例 #1
0
        /// <summary>
        /// Render an ascii map of stored data rooms around a specific radius
        /// </summary>
        /// <param name="room">the room to render the radius around</param>
        /// <param name="radius">the radius around the room to render</param>
        /// <param name="forAdmin">include edit links for paths and rooms?</param>
        /// <param name="withPathways">include paths at all?</param>
        /// <returns>a single string that is an ascii map</returns>
        public static string RenderRadiusMap(IRoom room, int radius, bool visibleOnly = false, bool forAdmin = true, bool withPathways = true, ILocale locale = null, MapRenderMode renderMode = MapRenderMode.Normal)
        {
            StringBuilder asciiMap = new StringBuilder();

            //Why?
            if (room == null)
            {
                //Don't show "add room" to non admins, if we're not requesting this for a locale and if the locale has actual rooms
                if (!forAdmin || locale == null || locale.Rooms().Count() > 0)
                {
                    return(string.Empty);
                }

                return(string.Format("<a href='#' class='addData pathway AdminAddInitialRoom' localeId='{0}' title='New Room'>Add Initial Room</a>", locale.BirthMark));
            }

            //1. Get world map
            ILocale ourLocale = room.ParentLocation;

            //2. Get slice of room from world map
            string[,,] map = Cartographer.TakeSliceOfMap(new Tuple <int, int>(Math.Max(room.Coordinates.X - radius, 0), room.Coordinates.X + radius)
                                                         , new Tuple <int, int>(Math.Max(room.Coordinates.Y - radius, 0), room.Coordinates.Y + radius)
                                                         , new Tuple <int, int>(Math.Max(room.Coordinates.Z - 1, 0), room.Coordinates.Z + 1)
                                                         , ourLocale.Interior.CoordinatePlane, true);

            //3. Flatten the map
            string[,] flattenedMap = Cartographer.GetSinglePlane(map, room.Coordinates.Z);

            //4. Render slice of room
            return(RenderMap(flattenedMap, visibleOnly, forAdmin, withPathways, room, renderMode));
        }
コード例 #2
0
        /// <summary>
        /// We just throw errors, no need for a return value
        /// </summary>
        private void VerifyLocale(ILocale locale)
        {
            if (locale == null)
            {
                throw new ArgumentNullException("Locale must not be null.");
            }

            if (locale.Rooms().Any())
            {
                throw new ArgumentOutOfRangeException("Locale must be devoid of rooms.");
            }

            if (locale.Template <ILocaleTemplate>().FitnessProblems)
            {
                throw new ArgumentOutOfRangeException("Zone must have data integrity.");
            }
        }