Exemplo n.º 1
0
        private bool ValidateCharacterCreation(LoginServer server, byte world, string name, int face, int hair,
                                               int hairColor, byte skin, int topId, int bottomId, int shoesId, int weaponId, Gender gender)
        {
            var error = name.Length < 4 ||
                        name.Length > 12 ||
                        server.CharacterExists(name, world) ||
                        CachedData.CreationData.ForbiddenNames.Any(x =>
                                                                   x.Equals(name, StringComparison.CurrentCultureIgnoreCase));

            switch (gender)
            {
            case Gender.Male:
                error |= CachedData.CreationData.MaleSkins.All(x => x != skin) ||
                         CachedData.CreationData.MaleFaces.All(x => x != face) ||
                         CachedData.CreationData.MaleHairs.All(x => x != hair) ||
                         CachedData.CreationData.MaleHairColors.All(x => x != hairColor) ||
                         CachedData.CreationData.MaleTops.All(x => x != topId) ||
                         CachedData.CreationData.MaleBottoms.All(x => x != bottomId) ||
                         CachedData.CreationData.MaleShoes.All(x => x != shoesId) ||
                         CachedData.CreationData.MaleWeapons.All(x => x != weaponId);
                break;

            case Gender.Female:
                error |= CachedData.CreationData.FemaleSkins.All(x => x != skin) ||
                         CachedData.CreationData.FemaleFaces.All(x => x != face) ||
                         CachedData.CreationData.FemaleHairs.All(x => x != hair) ||
                         CachedData.CreationData.FemaleHairColors.All(x => x != hairColor) ||
                         CachedData.CreationData.FemaleTops.All(x => x != topId) ||
                         CachedData.CreationData.FemaleBottoms.All(x => x != bottomId) ||
                         CachedData.CreationData.FemaleShoes.All(x => x != shoesId) ||
                         CachedData.CreationData.FemaleWeapons.All(x => x != weaponId);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(gender), gender, null);
            }

            return(error);
        }