<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RMUD.Commands
{
	internal class Look : CommandFactory
	{
		public override void Create(CommandParser Parser)
		{
			Parser.AddCommand(
                new Or(
				    new KeyWord("LOOK", false),
                    new KeyWord("L", false)),
				new LookProcessor(),
				"Look around at your suroundings.");
		}
	}

	internal class LookProcessor : ICommandProcessor
	{
		public void Perform(PossibleMatch Match, Actor Actor)
		{
			var location = Actor.Location as Room;
			if (location == null) throw new InvalidOperationException("Error: Actor not in room.");

			if (Actor.ConnectedClient != null)
			{
				var builder = new StringBuilder();

				builder.Append(location.Short);
				builder.Append("\r\n");
				builder.Append(location.Long.Expand(Actor, location));
				builder.Append("\r\n");

                var visibleThings = new List<Thing>(location.Contents.Where(t => !Object.ReferenceEquals(t, Actor)));

                for (int i = 0; i < visibleThings.Count;)
                {
                    var localeDescribable = visibleThings[i] as ILocaleDescriptionRules;
                    if (localeDescribable != null)
                    {
                        visibleThings.RemoveAt(i);
                        builder.Append(localeDescribable.LocaleDescription.Expand(Actor, localeDescribable as MudObject));
                        builder.Append("\r\n");
                    }
                    else
                    {
                        ++i;
                    }
                }

                //Display objects in room
                if (visibleThings.Count > 0)
                {
                    builder.Append("Also here: " + String.Join(", ", visibleThings.Select(t => t.Indefinite)));
                    builder.Append("\r\n");
                }

				//Display exits from room
                if (location.Links.Count > 0)
                {
                    builder.Append("Obvious exits:\r\n");

                    foreach (var link in location.Links)
                    {
                        builder.Append("  ");
                        builder.Append(Mud.CapFirst(link.Direction.ToString()));

                        if (link.Door != null && link.Door is Thing)<commit_msg>Fix #61. Added extra new-lines to locale description generated by look command.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RMUD.Commands
{
	internal class Look : CommandFactory
	{
		public override void Create(CommandParser Parser)
		{
			Parser.AddCommand(
                new Or(
				    new KeyWord("LOOK", false),
                    new KeyWord("L", false)),
				new LookProcessor(),
				"Look around at your suroundings.");
		}
	}

	internal class LookProcessor : ICommandProcessor
	{
		public void Perform(PossibleMatch Match, Actor Actor)
		{
			var location = Actor.Location as Room;
			if (location == null) throw new InvalidOperationException("Error: Actor not in room.");

			if (Actor.ConnectedClient != null)
			{
				var builder = new StringBuilder();

                builder.Append("\r\n");
				builder.Append(location.Short);
				builder.Append("\r\n");
				builder.Append(location.Long.Expand(Actor, location));
				builder.Append("\r\n\r\n");

                var visibleThings = new List<Thing>(location.Contents.Where(t => !Object.ReferenceEquals(t, Actor)));

                for (int i = 0; i < visibleThings.Count;)
                {
                    var localeDescribable = visibleThings[i] as ILocaleDescriptionRules;
                    if (localeDescribable != null)
                    {
                        visibleThings.RemoveAt(i);
                        builder.Append(localeDescribable.LocaleDescription.Expand(Actor, localeDescribable as MudObject));
                        builder.Append("\r\n\r\n");
                    }
                    else
                    {
                        ++i;
                    }
                }

                //Display objects in room
                if (visibleThings.Count > 0)
                {
                    builder.Append("Also here: " + String.Join(", ", visibleThings.Select(t => t.Indefinite)));
                    builder.Append("\r\n\r\n");
                }

				//Display exits from room
                if (location.Links.Count > 0)
                {
                    builder.Append("Obvious exits:\r\n");

                    foreach (var link in location.Links)
                    {
                        builder.Append("  ");
                        builder.Append(Mud.CapFirst(link.Direction.ToString()));

                        if (link.Door != null && link.Door is Thing)
{'fraction_non_alphanumeric': 0.10760282509347736, 'fraction_numerical': 0.0016618196925633569, 'mean_word_length': 1.5734901122394442, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4971452', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1168, 'n_words': 281}