MUDServer.Player.AddExitCommands C# (CSharp) Method

AddExitCommands() private method

private AddExitCommands ( Location l ) : void
l Location
return void
        private void AddExitCommands(Location l)
        {
            if (l == null)
                return;

            foreach (var ex in l.Exits) {
                _Commands.Insert(
                    ex.Name,
                    new CommandHandler(
                        new CommandHandler.PlayerCheckDelegate[] {
                            CheckPlayerIsAlive
                        },
                    delegate(Player p, string[] words) {
                        var ourExit = p.Location.Exits.Where(x => (x.Name.ToLower() == words[0])).First();
                        if (World.Locations.ContainsKey(ourExit.Target.ToLower()))
                            p.Location = World.Locations[ourExit.Target.ToLower()];
                        else {
                            Console.WriteLine("Warning: '{0}' exit '{1}' leads to undefined location '{2}'.", p.Location.Name, ourExit.Description, ourExit.Target);
                            p.SendMessage("Your attempt to leave via {0} is thwarted by a mysterious force.", ourExit.Description);
                            p.SendPrompt();
                        }
                        return null;
                    }));
            }
        }