Пример #1
0
        public List <NPC> CreateLineage(Random rand, NPCData data, FantasyDate referenceDate, ref Queue <string> lastNameCache, int depth = 0, int generations = 3, bool?isMale = null, bool hasSiblings = true)
        {
            List <NPC> result = new List <NPC>();

            GenerateLife(rand, data, referenceDate);
            if (isMale != null)
            {
                Male = (bool)isMale;
            }
            Name = Utility.GenerateName(rand, data.Race, Male ? Utility.NameType.FirstNameMale : Utility.NameType.FirstNameFemale) + " " + data.SurName;//new Faker().Name.FirstName(Male ? Bogus.DataSets.Name.Gender.Male : Bogus.DataSets.Name.Gender.Female) + " " + data.SurName;

            result.Add(this);


            int siblingCount = rand.Next(1, 11);

            if (siblingCount >= 9)
            {
                siblingCount = rand.Next(1, 9) + 3;
            }
            else if (siblingCount >= 7)
            {
                siblingCount = rand.Next(1, 7) + 2;
            }
            else if (siblingCount >= 5)
            {
                siblingCount = rand.Next(1, 5) + 1;
            }
            else if (siblingCount >= 3)
            {
                siblingCount = rand.Next(1, 4);
            }
            else if (siblingCount >= 0)
            {
                siblingCount = 0;
            }

            if (!hasSiblings)
            {
                siblingCount = 0;
            }

            for (int i = 0; i < siblingCount; i++)
            {
                NPC sibling = new NPC();
                sibling.GenerateLife(rand, data, referenceDate);
                sibling.Name               = Utility.GenerateName(rand, data.Race, sibling.Male ? Utility.NameType.FirstNameMale : Utility.NameType.FirstNameFemale) + " " + data.SurName;
                sibling.Family             = Family;
                sibling.AbsentParentReason = AbsentParentReason;

                Siblings.Add(sibling);
                result.Add(sibling);
            }

            FantasyDate youngest = BirthDate;

            for (int i = 0; i < Siblings.Count; i++)
            {
                for (int j = 0; j < Siblings.Count; j++)
                {
                    if (i != j)
                    {
                        Siblings[i].Siblings.Add(Siblings[j]);
                    }
                }
                Siblings[i].Siblings.Add(this);

                if (Siblings[i].BirthDate < youngest)
                {
                    youngest = Siblings[i].BirthDate;
                }
            }

            if (depth < generations)
            {
                NPC father = new NPC();
                result.AddRange(father.CreateLineage(rand, data, youngest, ref lastNameCache, depth + 1, generations: generations, isMale: true));

                NPC    mother  = new NPC();
                string surName = string.Empty;
                if (data.Race.hasLastName && lastNameCache.Count > 0)
                {
                    surName = lastNameCache.Dequeue();
                }
                data.SurName = surName;
                result.AddRange(mother.CreateLineage(rand, data, youngest, ref lastNameCache, depth + 1, generations: generations, isMale: false));

                Father = father;
                Mother = mother;
                for (int i = 0; i < Siblings.Count; i++)
                {
                    Siblings[i].Father = father;
                    Siblings[i].Mother = mother;

                    Siblings[i].GenerateFamilyScript();
                }

                Father.Children.Add(this);
                Mother.Children.Add(this);
                Father.Children.AddRange(Siblings);
                Mother.Children.AddRange(Siblings);
            }

            GenerateFamilyScript();

            return(result);
        }
Пример #2
0
        public void GenerateLife(Random rand, NPCData data, FantasyDate referenceDate)
        {
            GenerateID();

            BirthDate    = referenceDate - rand.Next((int)(data.Race.AverageLifeSpan * 0.2f), (int)(data.Race.AverageLifeSpan * 0.8f));
            DeathDate    = BirthDate + (data.Race.AverageLifeSpan - (data.Race.AverageLifeSpan / 4)) + rand.Next(1, data.Race.AverageLifeSpan / 2);
            Dead         = DeathDate < data.CurrentDate;
            Age          = Dead ? DeathDate - BirthDate : data.CurrentDate - BirthDate;
            Male         = rand.Next(0, 2) == 0;
            Race         = data.Race.Name;
            CityOfOrigin = data.CityOfOrigin;
            KnewParents  = rand.Next(1, 101) <= 95;

            int birthPlaceRoll = rand.Next(1, 101);
            List <Birthplace> birthPlaceOptions = new List <Birthplace>((IEnumerable <Birthplace>)System.Enum.GetValues(typeof(Birthplace)));

            for (int i = 0; i < birthPlaceOptions.Count; i++)
            {
                int val = (int)birthPlaceOptions[i];
                if (birthPlaceRoll <= val)
                {
                    BirthPlace = birthPlaceOptions[i];
                    break;
                }
            }

            int upbringingRoll = rand.Next(1, 101);
            List <Upbringing> upbringingOptions = new List <Upbringing>((IEnumerable <Upbringing>)System.Enum.GetValues(typeof(Upbringing)));

            for (int i = 0; i < upbringingOptions.Count; i++)
            {
                int val = (int)upbringingOptions[i];
                if (upbringingRoll <= val)
                {
                    Family = upbringingOptions[i];
                    break;
                }
            }

            Background = (Background)rand.Next(0, System.Enum.GetValues(typeof(Background)).Length);

            if (!KnewParents || Family != Upbringing.MotherAndFather)
            {
                AbsentParentReason = (AbsentParent)rand.Next(1, 5);
            }
            else
            {
                AbsentParentReason = AbsentParent.NotAbsent;
            }

            int childhoodRoll = rand.Next(1, 7) + rand.Next(1, 7) + rand.Next(1, 7);
            List <Childhood> childhoodOptions = new List <Childhood>((IEnumerable <Childhood>)System.Enum.GetValues(typeof(Childhood)));

            for (int i = 0; i < childhoodOptions.Count; i++)
            {
                int val = (int)childhoodOptions[i];
                if (childhoodRoll <= val)
                {
                    Childhood = childhoodOptions[i];
                    break;
                }
            }

            int lifeEvents = 1;

            if (Age > 100)
            {
                lifeEvents = rand.Next(1, 13);
            }
            else if (Age > 90)
            {
                lifeEvents = rand.Next(1, 11);
            }
            else if (Age > 70)
            {
                lifeEvents = rand.Next(1, 9);
            }
            else if (Age > 60)
            {
                lifeEvents = rand.Next(1, 7);
            }
            else if (Age > 21)
            {
                lifeEvents = rand.Next(1, 5);
            }

            List <LifeEventOption> lifeEventOptions = new List <LifeEventOption>((IEnumerable <LifeEventOption>)System.Enum.GetValues(typeof(LifeEventOption)));

            for (int i = 0; i < lifeEvents; i++)
            {
                int lifeEventRoll = rand.Next(1, 101);

                LifeEvent lifeEvent = new LifeEvent();
                for (int j = 0; j < lifeEventOptions.Count; j++)
                {
                    int val = (int)lifeEventOptions[j];
                    if (lifeEventRoll <= val)
                    {
                        lifeEvent.Event = lifeEventOptions[j];
                        break;
                    }
                }

                switch (lifeEvent.Event)
                {
                case LifeEventOption.Tragedy:
                    break;

                case LifeEventOption.GoodFortune:
                    break;

                case LifeEventOption.EnemyOfAdventurer:
                    break;

                case LifeEventOption.MetSomeoneImportant:
                    break;

                case LifeEventOption.WentOnAdventure:
                    break;

                case LifeEventOption.SupernaturalExperience:
                    break;

                case LifeEventOption.Crime:
                    break;

                case LifeEventOption.MagicEncounter:
                    break;

                case LifeEventOption.StrangeEvent:
                    break;
                }

                LifeEvents.Add(lifeEvent);
            }
        }