コード例 #1
0
        public void ExecuteCommand()
        {
            string[] command = Console.ReadLine()?.Split(' ');

            if (command?.Length > 0)
            {
                bool validKey = _player.CommandDictionary.ContainsKey(command[0]);

                if (validKey)
                {
                    var          commandType     = _player.CommandDictionary[command[0]];
                    IGameCommand commandInstance = (IGameCommand)Activator.CreateInstance(commandType);
                    commandInstance.ExecuteCommand(command, _player);
                    _prompt.ExecuteCommand(null, _player);
                }
                else
                {
                    Console.WriteLine("Huh?");
                }
            }
        }