Exemplo n.º 1
0
        public static FantasyNameGenerator GetCharacterNameGenerator(FantasyNameSettings fantasyNameSettings)
        {
            var fantasyNameGenerator = new FantasyNameGenerator();

            fantasyNameGenerator.Gender = fantasyNameSettings.Gender;

            if (fantasyNameSettings.ChosenClass != Classes.None)
            {
                INameGenerator maleNameGenerator = null;

                if (fantasyNameSettings.ChosenClass == Classes.Cleric)
                {
                    maleNameGenerator = new MaleClericFirstNameGenerator();
                }

                if (fantasyNameSettings.ChosenClass == Classes.Rogue)
                {
                    maleNameGenerator = new MaleRogueFirstNameGenerator();
                }

                if (fantasyNameSettings.ChosenClass == Classes.Warrior)
                {
                    maleNameGenerator = new MaleWarriorFirstNameGenerator();
                }

                if (fantasyNameSettings.ChosenClass == Classes.Wizard)
                {
                    maleNameGenerator = new MaleWizardFirstNameGenerator();
                }

                if (fantasyNameSettings.Gender == Gender.Male)
                {
                    fantasyNameGenerator.FirstNameGenerator = maleNameGenerator;
                }
                else
                {
                    fantasyNameGenerator.FirstNameGenerator = new FemaleWrapperNameGenerator(maleNameGenerator);
                }

                fantasyNameGenerator.LastNameGenerator = new LastNameGenerator();
            }
            else
            {
                fantasyNameGenerator.FirstNameGenerator = new RaceNameGenerator(fantasyNameSettings.ChosenRace);
                fantasyNameGenerator.LastNameGenerator  = new RaceNameGenerator(fantasyNameSettings.ChosenRace);
            }

            if (fantasyNameSettings.IncludePostfix)
            {
                if (fantasyNameSettings.ChosenClass == Classes.Wizard)
                {
                    fantasyNameGenerator.PostfixNameGenerator = new PostfixWizardGenerator();
                }
                else if (fantasyNameSettings.ChosenRace != Race.None)
                {
                    fantasyNameGenerator.PostfixNameGenerator = new VilePostfixGenerator();
                }
                else
                {
                    fantasyNameGenerator.PostfixNameGenerator = new PostfixGenerator();
                }
            }

            return(fantasyNameGenerator);
        }
        public static FantasyNameGenerator FromSettingsInfo(FantasyNameSettings fantasyNameSettings)
        {
            var fantasyNameGenerator = new FantasyNameGenerator();

            fantasyNameGenerator.Gender = fantasyNameSettings.Gender;

            // TODO: use type matching/strategy pattern here or whatever you wanna call it.

            // No prefix included in version 1
            //if(IncludePrefix)
            //	compositeNameGenerator.PrefixGenerator = new PrefixGenerator();

            if (fantasyNameSettings.ChosenClass != Classes.None)
            {
                INameGenerator maleNameGenerator = null;

                if (fantasyNameSettings.ChosenClass == Classes.Cleric)
                {
                    maleNameGenerator = new MaleClericFirstNameGenerator();
                }

                if (fantasyNameSettings.ChosenClass == Classes.Rogue)
                {
                    maleNameGenerator = new MaleRogueFirstNameGenerator();
                }

                if (fantasyNameSettings.ChosenClass == Classes.Warrior)
                {
                    maleNameGenerator = new MaleWarriorFirstNameGenerator();
                }

                if (fantasyNameSettings.ChosenClass == Classes.Wizard)
                {
                    maleNameGenerator = new MaleWizardFirstNameGenerator();
                }

                if (fantasyNameSettings.Gender == Gender.Male)
                {
                    fantasyNameGenerator.FirstNameGenerator = maleNameGenerator;
                }
                else
                {
                    fantasyNameGenerator.FirstNameGenerator = new FemaleWrapperNameGenerator(maleNameGenerator);
                }

                fantasyNameGenerator.LastNameGenerator = new LastNameGenerator();
            }
            else
            {
                fantasyNameGenerator.FirstNameGenerator = new RaceNameGenerator(fantasyNameSettings.ChosenRace);
                fantasyNameGenerator.LastNameGenerator  = new RaceNameGenerator(fantasyNameSettings.ChosenRace);
            }


            if (fantasyNameSettings.IncludePostfix)
            {
                if (fantasyNameSettings.ChosenClass == Classes.Wizard)
                {
                    fantasyNameGenerator.PostfixNameGenerator = new PostfixWizardGenerator();
                }
                else if (fantasyNameSettings.ChosenRace != Race.None)
                {
                    fantasyNameGenerator.PostfixNameGenerator = new VilePostfixGenerator();
                }
                else
                {
                    fantasyNameGenerator.PostfixNameGenerator = new PostfixGenerator();
                }
            }

            if (fantasyNameSettings.IncludeHomeland)
            {
                fantasyNameGenerator.LandNameGenerator = new LandGenerator();
            }

            return(fantasyNameGenerator);
        }