public static void ParseCommand(string input, PlayerSetup.Player playerData, Room.Room room = null) { if (string.IsNullOrEmpty(input.Trim())) { HubContext.SendToClient("You need to enter a command, type help if you need it.", playerData.HubGuid); return; } //testing string enteredCommand = input; string[] commands = enteredCommand.Split(' '); string commandKey = commands[0]; string commandOptions = string.Empty; // testing if (commands.Length >= 2) { if ((commands[1].Equals("in", StringComparison.InvariantCultureIgnoreCase) || commands[1].Equals("at", StringComparison.InvariantCultureIgnoreCase))) { commandKey = commands[0] + " " + commands[1]; commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(commands[2], StringComparison.Ordinal)).Trim(); } else if (commandKey.Equals("c", StringComparison.InvariantCultureIgnoreCase) || commandKey.Equals("cast", StringComparison.InvariantCultureIgnoreCase) && commands.Length > 1) { commandKey = commands[0] + " " + commands[1]; commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(commands[0], StringComparison.Ordinal)).Trim(); } else { commandOptions = enteredCommand.Substring(enteredCommand.IndexOf(' ', 1)).Trim(); } } //TODO: do this only once var command = Command.Commands(commandOptions, commandKey, playerData, room); var fire = command.FirstOrDefault(x => x.Key.StartsWith(commandKey, StringComparison.InvariantCultureIgnoreCase)); if (fire.Value != null) { fire.Value(); } else { HubContext.SendToClient("Sorry you can't do that.", playerData.HubGuid); } playerData.LastCommandTime = DateTime.UtcNow; Score.UpdateUiPrompt(playerData); }
//public static Dictionary<string, Action> commandList { get; set; } public static Dictionary <string, Action> Events(string eventName, PlayerSetup.Player player, PlayerSetup.Player mob, Room.Room room, string option = "", string calledBy = "") { var eventList = new Dictionary <String, Action>(); eventList.Add("greet", () => Greeting.greet(player, mob, room)); eventList.Add("tutorial", () => Tutorial.setUpTut(player, room, option, calledBy)); eventList.Add("rescue", () => Tutorial.setUpAwakening(player, room, option, calledBy)); eventList.Add("awakening awake", () => Tutorial.setUpRescue(player, room, option, calledBy)); eventList.Add("Give Leather Quest", () => { if (player.QuestLog.FirstOrDefault(x => x.Name == AnkerQuests.TutorialLeatherQuest().Name) == null) { player.QuestLog.Add(AnkerQuests.TutorialLeatherQuest()); HubContext.SendToClient( "<span class='questColor'>New Quest added: " + AnkerQuests.TutorialLeatherQuest().Name + "<br />" + AnkerQuests.TutorialLeatherQuest().Description + "</span>", player.HubGuid); } }); eventList.Add("wearEQ", () => Tutorial.setUpRescue(player, room, option, calledBy)); eventList.Add("AnkerIdiot", () => VilliageIdiot.Annoy(player, mob, room)); return(eventList); }