Example #1
0
        public Exits GetRoomExit(string direction = null)
        {
            GetRoomExits();
            Exits result = null;

            if (!string.IsNullOrEmpty(direction))
            {
                result = RoomExits.Where(e => e.Direction.ToUpper() == direction.ToUpper()).SingleOrDefault();
            }
            else
            {
                result = RoomExits.FirstOrDefault();
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// This method should be called after the room has been instantiated to prevent a stack voerflow since it will become a recursive call otherwise.
        /// </summary>
        public void GetRoomExits()
        {
            MongoCollection doorCollection = MongoUtils.MongoData.GetCollection("World", "Doors");

            List <Exits> exitList = new List <Exits>();

            foreach (BsonDocument doc in Exits)
            {
                Exits exit = new Exits();
                exit.availableExits.Add(doc["Name"].AsString, GetRoom(doc["LeadsToRoom"].AsString)); //causing stackoverflow because exits point to each other
                //if it has door grab that as well
                //this query looks for a door with an id of either "roomid-adjecentroomid" or "adjacentroomid-roomid"
                string oneWay     = Id.ToString() + "-" + exit.availableExits[doc["Name"].AsString].Id;
                string anotherWay = exit.availableExits[doc["Name"].AsString].Id + "-" + Id.ToString();

                Door door = Door.GetDoor(oneWay, anotherWay);

                if (door != null)
                {
                    exit.doors.Add(doc["Name"].AsString, door);
                }

                exit.Direction = doc["Name"].AsString.ToLower();

                //door description overrides it unless it's blank
                if (exit.doors.Count > 0)
                {
                    string doorDescription = exit.doors.ContainsKey(exit.Direction.CamelCaseWord()) == true ? (exit.doors[exit.Direction.CamelCaseWord()].Destroyed == true ? exit.doors[exit.Direction.CamelCaseWord()].Description + " that leads to " + exit.Description : exit.doors[exit.Direction.CamelCaseWord()].Description) : "";
                    if (!string.IsNullOrEmpty(doorDescription))
                    {
                        exit.Description = doorDescription;
                    }
                }

                exitList.Add(exit);
            }
            RoomExits = exitList;
        }
Example #3
0
        private static string GetExitDescription(Exits exit, Room room)
        {
            //there's a lot of sentence
            string[] vowel = new string[] { "a", "e", "i", "o", "u" };

            if (room.IsDark) {
                exit.Description = "something";
            }

            if (string.IsNullOrEmpty(exit.Description)) {
                exit.Description = exit.availableExits[exit.Direction.CamelCaseWord()].Title.ToLower();
            }

            if (exit.Description.Contains("that leads to")) {
                exit.Description += exit.availableExits[exit.Direction.CamelCaseWord()].Title.ToLower();
            }

            string directionCorrected = "To the " + exit.Direction.CamelCaseWord().FontColor(Utils.FontForeColor.CYAN) + " there is ";

            if (String.Compare(exit.Direction, "up", true) == 0 || String.Compare(exit.Direction, "down", true) == 0) {
                if (!room.IsDark) {
                    directionCorrected = exit.Description.UppercaseFirstWordInString();
                }
                else {
                    directionCorrected = "something";
                }

                directionCorrected += " leads " + exit.Direction.CamelCaseWord().FontColor(Utils.FontForeColor.CYAN) + " towards ";

                if (!room.IsDark) {
                    exit.Description = "somewhere";
                }
                else {
                    exit.Description = exit.availableExits[exit.Direction.CamelCaseWord()].Title.ToLower();
                }
            }

            if (!exit.Description.Contains("somewhere") && vowel.Contains(exit.Description[0].ToString())) {
                directionCorrected += "an ";
            }
            else if (!exit.Description.Contains("somewhere") && exit.Description != "something") {
                directionCorrected += "a ";
            }

            return (directionCorrected + exit.Description + ".");
        }
Example #4
0
File: Room.cs Project: vadian/Novus
        /// <summary>
        /// This method should be called after the room has been instantiated to prevent a stack voerflow since it will become a recursive call otherwise.
        /// </summary>
        public void GetRoomExits()
        {
            MongoCollection doorCollection = MongoUtils.MongoData.GetCollection("World", "Doors");

            List<Exits> exitList = new List<Exits>();

            foreach (BsonDocument doc in Exits) {
                Exits exit = new Exits();
                exit.availableExits.Add(doc["Name"].AsString, GetRoom(doc["LeadsToRoom"].AsString)); //causing stackoverflow because exits point to each other
                //if it has door grab that as well
                //this query looks for a door with an id of either "roomid-adjecentroomid" or "adjacentroomid-roomid"
                string oneWay = Id.ToString() + "-" + exit.availableExits[doc["Name"].AsString].Id;
                string anotherWay = exit.availableExits[doc["Name"].AsString].Id + "-" + Id.ToString();

                Door door = Door.GetDoor(oneWay, anotherWay);

                if (door != null) {
                    exit.doors.Add(doc["Name"].AsString, door);
                }

                exit.Direction = doc["Name"].AsString.ToLower();

                //door description overrides it unless it's blank
                if (exit.doors.Count > 0) {
                    string doorDescription = exit.doors.ContainsKey(exit.Direction.CamelCaseWord()) == true ? (exit.doors[exit.Direction.CamelCaseWord()].Destroyed == true ? exit.doors[exit.Direction.CamelCaseWord()].Description + " that leads to " + exit.Description : exit.doors[exit.Direction.CamelCaseWord()].Description) : "";
                    if (!string.IsNullOrEmpty(doorDescription)) exit.Description = doorDescription;
                }

                exitList.Add(exit);
            }
            RoomExits = exitList;
        }
Example #5
0
        /// <summary>
        /// This method should be called after the room has been instantiated to prevent a stack voerflow since it will become a recursive call otherwise.
        /// </summary>
        public void GetRoomExits() {
            List<Exits> exitList = new List<Exits>();

            foreach (var doc in Exits) {
                Exits exit = new Exits();
                exit.availableExits.Add((RoomExits)Enum.Parse(typeof(RoomExits), doc.Name), GetRoom(doc.LeadsToRoom)); //causing stackoverflow because exits point to each other
                //if it has door grab that as well
                //this query looks for a door with an id of either "roomid-adjecentroomid" or "adjacentroomid-roomid"
                string oneWay = Id.ToString() + "-" + exit.availableExits[(RoomExits)Enum.Parse(typeof(RoomExits), doc.Name)].Id;
                string anotherWay = exit.availableExits[(RoomExits)Enum.Parse(typeof(RoomExits), doc.Name)].Id + "-" + Id.ToString();

                IDoor door = Door.GetDoor(oneWay, anotherWay);
                RoomExits exitDirection = (RoomExits)Enum.Parse(typeof(RoomExits), doc.Name);
                if (door != null) {
                    exit.doors.Add(exitDirection, door);
                }

                exit.Direction = exitDirection.ToString().ToLower();

                //door description overrides it unless it's blank
                if (exit.doors.Count > 0) {
                    string doorDescription = exit.doors.ContainsKey(exitDirection) ? (exit.doors[exitDirection].Destroyed == true ? exit.doors[exitDirection].Description + " that leads to " + exit.Description : exit.doors[exitDirection].Description) : "";
                    if (!string.IsNullOrEmpty(doorDescription)) exit.Description = doorDescription;
                }

                exitList.Add(exit);
            }
            RoomExits = exitList;
        }