public void ExecuteCommand(UserCommand userCommand, GameState gameState) { var command = LocalCommands.FirstOrDefault(x => string.Equals(x.CommandText, userCommand.CommandText.Trim(), StringComparison.InvariantCultureIgnoreCase) || x.Abbreviations.Contains(userCommand.CommandText.Trim()) ); if (command == null) { Game.WriteLine($"{userCommand.CommandText} is not a valid command.", PcmColor.Red, null, GameConsoles.Input); Game.WriteLine("Type [help] to see a list of commands.", PcmColor.Red, null, GameConsoles.Input); return; } if (command.Command == null) { command.Execute(userCommand, gameState); return; } CommandRunner.Run(command.Command(userCommand, gameState)); }
public void HandleInput(UserCommand command) { CommandsGroup.ExecuteCommand(command, GameState); }