Exemple #1
0
        public void SendRoomDescription(Room room, bool brief = false)
        {
            var message = new RoomDescriptionMessage()
            {
                IsCurrentRoom = room == this.Room
            };

            var illumination = room.Illumination + Illumination;

            message.LightLevel = LightLevels.Get(illumination);


            if (LightLevels.IsTooDarkToSee(message.LightLevel))
            {
                // Too dark to see. Send the light information and that's it.
                message.CannotSee = true;
                SendMessage(message);
                return;
            }

            //TODO: Check to see if the user is blind? Somehow. I have no idea yet.

            if (!brief)
            {
                message.Description = room.TextBlock.Text;
            }

            message.Name   = room.Name;
            message.RoomId = room.Id;

            var exits = room.GetExits();

            message.Exits        = exits.Select(x => new ExitDescription(x, room)).ToArray();
            message.Actors       = room.VisibleActors(this).Select(x => new ActorDescription(x)).ToArray();
            message.VisibleItems = room.Items.Where(x => x.HiddenTime == null).OrderBy(x => x.Name).Select(x => new ItemDescription(x)).ToArray();
            message.VisibleCash  = Game.Data.AllCurrencies.Select(x => new CurrencyDescription(x, room.GetCash(x))).Where(x => x.Amount != 0).ToArray();

            message.FoundItems = room.Items.Where(x => x.HiddenTime != null && x.UsersWhoFoundMe.Contains(this)).OrderBy(x => x.Name).Select(x => new ItemDescription(x)).ToArray();
            message.FoundCash  = room.GetTotalCashUserCanSee(this).Where(x => x.KnownHidden > 0).Select(x => new CurrencyDescription(x.Currency, x.KnownHidden)).ToArray();

            SendMessage(message);
        }