예제 #1
0
        /// <summary>
        /// The Display Message Command
        ///
        /// <param name="messageId" <see cref="uint"> Message ID</ param >
        /// <param name="messageControl" <see cref="byte"> Message Control</ param >
        /// <param name="startTime" <see cref="DateTime"> Start Time</ param >
        /// <param name="durationInMinutes" <see cref="ushort"> Duration In Minutes</ param >
        /// <param name="message" <see cref="string"> Message</ param >
        /// <param name="extendedMessageControl" <see cref="byte"> Extended Message Control</ param >
        /// <returns> the command result Task </returns>
        /// </summary>
        public Task <CommandResult> DisplayMessageCommand(uint messageId, byte messageControl, DateTime startTime, ushort durationInMinutes, string message, byte extendedMessageControl)
        {
            DisplayMessageCommand command = new DisplayMessageCommand();

            // Set the fields
            command.MessageId              = messageId;
            command.MessageControl         = messageControl;
            command.StartTime              = startTime;
            command.DurationInMinutes      = durationInMinutes;
            command.Message                = message;
            command.ExtendedMessageControl = extendedMessageControl;

            return(Send(command));
        }
        /// <summary>
        /// Checks if the user input is correct and creates corresponding command
        /// </summary>
        /// <param name="command">User input command</param>
        /// <returns>The created command</returns>
        private ICommand ProcessGuessAndReturnAppropriateCommand(string command)
        {
            ICommand commandExecutor = null;

            if (this.FourDigitNumberPattern.IsMatch(command) && (command.Length == 4))
            {
                if (this.Data.GuessAttempts <= this.Data.GuessAttemptsMaxValue)
                {
                    if (command.Equals(this.Data.NumberToGuess))
                    {
                        commandExecutor = new WinGameCommand(this.Notifier, this.Scoreboard, this.Data);
                    }
                    else
                    {
                        commandExecutor = new GuessCommand(this.Data, this.Notifier, command);
                    }
                }
                else
                {
                    commandExecutor = new DisplayMessageCommand(this.Notifier, false, MaxGuessesLimitMessage);
                }
            }
            else
            {
                commandExecutor = new DisplayMessageCommand(this.Notifier, true, InputWarningMessage);
            }

            return commandExecutor;
        }