Пример #1
0
        /// <summary>
        /// ProcessInput is used to receive the user input during this state.
        /// </summary>
        /// <param name="command">The command text to be processed.</param>
        public override void ProcessInput(string command)
        {
            if (this.ValidateCharacterName(ref command))
            {
                // The name is valid, but has it been taken already?
               var repository = new PlayerRepository();

                if (repository.GetPlayerByUserName(command) == null)
                {
                    if (this.StateMachine != null)
                    {
                        this.StateMachine.NewCharacter.Name = command;
                        this.StateMachine.HandleNextStep(this, StepStatus.Success);
                    }
                }
                else
                {
                    this.Session.Write("I'm sorry, that name is already taken. Please choose another.");
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Loads a player based on name
 /// </summary>
 /// <param name="playerName">Name of the player</param>
 public void Load(string playerName)
 {
     var repository = new PlayerRepository();
     this.PlayerData = repository.GetPlayerByUserName(playerName);
 }