Ejemplo n.º 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.");
                }
            }
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
        /// <summary>Saves this player.</summary>
        public override void Save()
        {
            // Save the player's basic info.
            var repository = new PlayerRepository();

            if (this.ID == 0)
            {
                repository.Add(this.PlayerData);
                this.ID = this.PlayerData.ID;
            }
            else
            {
                repository.Update(this.PlayerData);
            }

            /* Disabling roles for now
            // Deal with the player roles.
            var roleRepository = new PlayerRoleRepository();
            ICollection<PlayerRoleRecord> existingRoles = roleRepository.FetchAllPlayerRoleRecordsForPlayer(this.Id);

            var toAdd = new List<PlayerRoleRecord>();

            foreach (var roleRecord in this.RoleData)
            {
                var currRole = this.FindRole(roleRecord.ID, existingRoles);

                if (currRole == null)
                {
                    // Add it to the list to add
                    toAdd.Add(currRole);
                }
                else
                {
                    // Remove the role since there is nothing to do.
                    existingRoles.Remove(currRole);
                }
            }

            roleRepository.AddRolesToPlayer(toAdd);

            // Delete any roles still in the existing roles collection as they
            // are no longer assigned to the person.
            foreach (PlayerRoleRecord existingRole in existingRoles)
            {
                roleRepository.Remove(existingRole);
            }
            */

            // @@@ TODO: Need to do this with all the other custom lists and collections, like friends and inventory.
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Loads the specified player by their id.
 /// </summary>
 /// <param name="playerId">The player's id.</param>
 public void Load(int playerId)
 {
     var repository = new PlayerRepository();
     this.PlayerData = repository.GetById(playerId);
 }