예제 #1
0
        /// <summary>
        /// Removes the given doorway from this room instance.
        /// </summary>
        /// <param name="doorway">The doorway being removed from the room.</param>
        /// <returns>Returns an awaitable Task</returns>
        public Task RemoveDoorwayFromRoom(IDoorway doorway)
        {
            if (doorway == null)
            {
                return(Task.FromResult(0));
            }

            this.doorways.Remove(doorway);
            return(Task.FromResult(0));
        }
예제 #2
0
        /// <summary>
        /// Removes the doorway associated with the travel direction given.
        /// </summary>
        /// <param name="travelDirection">The travel direction that must be removed from the room.</param>
        /// <returns>Returns an awaitable Task</returns>
        public Task RemoveDoorwayFromRoom(ITravelDirection travelDirection)
        {
            if (travelDirection == null)
            {
                return(Task.FromResult(0));
            }

            IDoorway door = this.doorways.FirstOrDefault(d => d.DepartureDirection == travelDirection);

            if (door == null)
            {
                throw new InvalidOperationException($"The {travelDirection.Direction} travel direction does not have a door assigned to it in {this.Name}");
            }

            return(this.RemoveDoorwayFromRoom(door));
        }
예제 #3
0
        /// <summary>
        /// Adds a given doorway to this room instance.
        /// </summary>
        /// <param name="doorway">The doorway doorway to add.</param>
        /// <returns>Returns an awaitable Task</returns>
        public async Task AddDoorwayToRoom(IDoorway doorway)
        {
            if (doorway.ArrivalRoom == null)
            {
                throw new InvalidRoomException(this, "You can not add a doorway to a room without setting an arrival room for the door.");
            }
            else if (doorway.DepartureRoom == null)
            {
                throw new InvalidRoomException(this, "You can not add a doorway to a room without setting a departure room for the door.");
            }
            else if (doorway.DepartureDirection == null)
            {
                throw new InvalidRoomException(this, "You must set the travel direction required in order to depart this room through the doorway.");
            }

            await doorway.Initialize();

            this.doorways.Add(doorway);
        }
예제 #4
0
        /// <summary>
        /// Removes the given doorway from this room instance.
        /// </summary>
        /// <param name="doorway">The doorway being removed from the room.</param>
        /// <returns>Returns an awaitable Task</returns>
        public Task RemoveDoorwayFromRoom(IDoorway doorway)
        {
            if (doorway == null)
            {
                return Task.FromResult(0);
            }

            this.doorways.Remove(doorway);
            return Task.FromResult(0);
        }
예제 #5
0
        /// <summary>
        /// Adds a given doorway to this room instance.
        /// </summary>
        /// <param name="doorway">The doorway doorway to add.</param>
        /// <returns>Returns an awaitable Task</returns>
        public async Task AddDoorwayToRoom(IDoorway doorway)
        {
            if (doorway.ArrivalRoom == null)
            {
                throw new InvalidRoomException(this, "You can not add a doorway to a room without setting an arrival room for the door.");
            }
            else if (doorway.DepartureRoom == null)
            {
                throw new InvalidRoomException(this, "You can not add a doorway to a room without setting a departure room for the door.");
            }
            else if (doorway.DepartureDirection == null)
            {
                throw new InvalidRoomException(this, "You must set the travel direction required in order to depart this room through the doorway.");
            }

            await doorway.Initialize();
            this.doorways.Add(doorway);
        }