Beispiel #1
0
        public bool ExecuteCommand(ClientCommandInfo cmdInfo, PlayerDetails playerDetails)
        {
            bool executed = false;

            try
            {
                foreach (ICommandHandlingStrategy strategy in _cmdHandlingStrategyList)
                {
                    if (strategy.ValidateExecution(cmdInfo))
                    {
                        executed = strategy.Execute(playerDetails);
                        if (executed)
                        {
                            //_logger.UpdateLog($"CMD [{cmdInfo.CommandTxt}] executed by [{strategy.GetType().ToString()}]");
                            break;
                        }
                    }
                }

                if (!executed)
                {
                    _logger.UpdateLog($"CMD [{cmdInfo.CommandTxt}] cannot be executed!");
                }
            }
            catch (Exception exception)
            {
                _logger.UpdateLog($"Command execution error, TCP client ID [{cmdInfo.ClientInfo.ClientId}]: {exception.Message} | {exception.StackTrace}");
                _logger.UpdateLog($"with command [{cmdInfo.CommandTxt}]");
            }

            return(executed);
        }
Beispiel #2
0
        public bool ValidateExecution(ClientCommandInfo cmdInfo)
        {
            bool valid = false;

            _cmdInfo     = cmdInfo;
            _cmdElements = cmdInfo.CommandTxt.Split(' ');

            if (_cmdElements.Length > 0 && _cmdElements[0].Equals(CmdChooseCharacterStrategy._keyWord, GlobalData.InputDataStringComparison))
            {
                valid = true;
            }

            return(valid);
        }
Beispiel #3
0
        public bool ValidateExecution(ClientCommandInfo cmdInfo)
        {
            bool valid = false;

            if
            (
                cmdInfo.CommandTxt.Length >= _keyWord.Length &&
                cmdInfo.CommandTxt.Substring(0, _keyWord.Length).Equals(_keyWord, GlobalData.InputDataStringComparison)
            )
            {
                _rawText = cmdInfo.CommandTxt;
                valid    = true;
            }

            return(valid);
        }
        public bool ValidateExecution(ClientCommandInfo cmdInfo)
        {
            bool valid = false;

            lock (_dataLock)
            {
                if
                (
                    cmdInfo.CommandTxt.Length >= _keyWord.Length &&
                    cmdInfo.CommandTxt.Substring(0, _keyWord.Length).Equals(_keyWord, GlobalData.InputDataStringComparison)
                )
                {
                    _cmdInfo     = cmdInfo;
                    _cmdElements = cmdInfo.CommandTxt.Split(' ');
                    valid        = true;
                }
            }

            return(valid);
        }
 public bool ValidateExecution(ClientCommandInfo cmdInfo)
 {
     return(cmdInfo.CommandTxt.Equals(_keyWord, GlobalData.InputDataStringComparison));
 }