Ejemplo n.º 1
0
        private bool IsValidChar()
        {
            if (_config.GameplayConfig.OtherConfig.CharCreationBlocked)
            {
                _client.SendPacket(new CharCreateFail(CharCreateFailReason.CharCreationBlocked));
                return(false);
            }

            if (_client.AccountChars.Count >= _config.GameplayConfig.OtherConfig.MaxCharactersByAccount)
            {
                _client.SendPacket(new CharCreateFail(CharCreateFailReason.TooManyCharsOnAccount));
                return(false);
            }

            if (_config.GameplayConfig.OtherConfig.ForbiddenCharNames.Contains(_name))
            {
                _client.SendPacket(new CharCreateFail(CharCreateFailReason.IncorrectName));
                return(false);
            }

            if (!StringHelper.IsValidPlayerName(_name))
            {
                _client.SendPacket(new CharCreateFail(CharCreateFailReason.InvalidNamePattern));
                return(false);
            }

            if (_playerService.CheckIfPlayerNameExists(_name))
            {
                _client.SendPacket(new CharCreateFail(CharCreateFailReason.NameAlreadyExists));
                return(false);
            }

            if (!Enum.IsDefined(typeof(ClassRace), _race) ||
                !Enum.IsDefined(typeof(HairStyleId), _hairStyle) ||
                !Enum.IsDefined(typeof(HairColor), _hairColor) ||
                !Enum.IsDefined(typeof(Face), _face))
            {
                _client.SendPacket(new CharCreateFail(CharCreateFailReason.CreationFailed));
                return(false);
            }

            if (!HairStyle.Values.Any(filter => (filter.Id == (HairStyleId)_hairStyle) &&
                                      filter.Sex.Contains((Gender)_sex)))
            {
                _client.SendPacket(new CharCreateFail(CharCreateFailReason.CreationFailed));
                return(false);
            }

            if (!ClassId.Values.Any(filter => (filter.Level() == 0) &&
                                    (filter.ClassRace == (ClassRace)_race) &&
                                    (filter.Id == (ClassIds)_classId)))
            {
                _client.SendPacket(new CharCreateFail(CharCreateFailReason.CreationFailed));
                return(false);
            }

            return(true);
        }