public static bool Start(String basePath) { try { InitializeDatabase(basePath); var settings = GetObject("settings") as Settings; if (settings == null) { throw new InvalidProgramException("No settings object is defined in the database!"); } ParserCommandHandler = new ParserCommandHandler(); LoginCommandHandler = new LoginCommandHandler(); ActionExecutionThread = new Thread(CommandProcessingThread); ActionExecutionThread.Start(); Console.WriteLine("Engine ready with path " + basePath + "."); } catch (Exception e) { Console.WriteLine("Failed to start mud engine."); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); throw e; } return(true); }
public static bool Start(String basePath) { try { InitializeDatabase(basePath); var settings = GetObject("settings") as Settings; if (settings == null) throw new InvalidProgramException("No settings object is defined in the database!"); ParserCommandHandler = new ParserCommandHandler(); LoginCommandHandler = new LoginCommandHandler(); ActionExecutionThread = new Thread(CommandProcessingThread); ActionExecutionThread.Start(); Console.WriteLine("Engine ready with path " + basePath + "."); } catch (Exception e) { Console.WriteLine("Failed to start mud engine."); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); throw e; } return true; }
private static void InitializeCommandProcessor() { DefaultParser = new CommandParser(); foreach (var assembly in IntegratedModules) { DiscoverCommandFactories(assembly, DefaultParser); } ParserCommandHandler = new ParserCommandHandler(); }
public DisambigCommandHandler( MudObject Actor, CommandParser.MatchedCommand MatchedCommand, ParserCommandHandler ParentHandler) { this.ParentHandler = ParentHandler; this.MatchedCommand = MatchedCommand; // Find an object parameter such that // a) each match has a parameter with that name // b) at least one match has a value different from the others var foundAmbiguousArgument = false; // Note that we iterate only over the arguments in the first match. If the first match doesn't have the // argument, that argument can't satisfy condition a above. foreach (var argument in MatchedCommand.Matches[0]) { // It's only possible to disambiguate on MudObjects. If any match - including the first one - has // a value for that argument that is not a MudObject, disambiguation will fail. if (argument.Value is MudObject) { var uniqueMatchables = new List <MudObject>(); var rejected = false; foreach (var match in MatchedCommand.Matches) { if (match.ContainsKey(argument.Key) && match[argument.Key] is MudObject) { var matchableObject = match[argument.Key] as MudObject; if (!uniqueMatchables.Contains(matchableObject)) { uniqueMatchables.Add(matchableObject); } } else { rejected = true; break; } } if (!rejected && uniqueMatchables.Count > 1) { // Disambiguate on this object. DisambigArgument = argument.Key; DisambigObjects = uniqueMatchables; foundAmbiguousArgument = true; break; } } } if (foundAmbiguousArgument) { var response = new StringBuilder(); response.Append("Which did you mean?\r\n"); for (var i = 0; i < DisambigObjects.Count; ++i) { response.Append(String.Format("{0}: {1}\r\n", i, Core.GlobalRules.ConsiderValueRule <String>("printed name", Actor, DisambigObjects[i], "the"))); } Core.SendMessage(Actor, response.ToString()); } else { Core.SendMessage(Actor, "I couldn't figure out how to disambiguate that command."); } }
private static void InitializeCommandProcessor() { DiscoverCommandFactories(DefaultParser); ParserCommandHandler = new ParserCommandHandler(); }
public DisambigCommandHandler( Actor Actor, CommandParser.MatchedCommand MatchedCommand, ParserCommandHandler ParentHandler) { this.ParentHandler = ParentHandler; this.MatchedCommand = MatchedCommand; // Find an object parameter such that // a) each match has a parameter with that name // b) at least one match has a value different from the others var foundAmbiguousArgument = false; // Note that we iterate only over the arguments in the first match. If the first match doesn't have the // argument, that argument can't satisfy condition a above. foreach (var argument in MatchedCommand.Matches[0]) { // It's only possible to disambiguate on MudObjects. If any match - including the first one - has // a value for that argument that is not a MudObject, disambiguation will fail. if (argument.Value is MudObject) { var uniqueMatchables = new List<MudObject>(); var rejected = false; foreach (var match in MatchedCommand.Matches) { if (match.ContainsKey(argument.Key) && match[argument.Key] is MudObject) { var matchableObject = match[argument.Key] as MudObject; if (!uniqueMatchables.Contains(matchableObject)) uniqueMatchables.Add(matchableObject); } else { rejected = true; break; } } if (!rejected && uniqueMatchables.Count > 1) { // Disambiguate on this object. DisambigArgument = argument.Key; DisambigObjects = uniqueMatchables; foundAmbiguousArgument = true; break; } } } if (foundAmbiguousArgument) { var response = new StringBuilder(); response.Append("Which did you mean?\r\n"); for (var i = 0; i < DisambigObjects.Count; ++i) response.Append(String.Format("{0}: {1}\r\n", i, Core.GlobalRules.ConsiderValueRule<String>("printed name", Actor, DisambigObjects[i], "the"))); MudObject.SendMessage(Actor, response.ToString()); } else { MudObject.SendMessage(Actor, "I couldn't figure out how to disambiguate that command."); } }
private static void InitializeCommandProcessor() { DefaultParser = new CommandParser(); foreach (var assembly in IntegratedModules) DiscoverCommandFactories(assembly, DefaultParser); ParserCommandHandler = new ParserCommandHandler(); }