public FamilyMember(FamilyMemberTypeEnum type, City baseCity, bool isMale, DateTime gameDate, string forceSurname, bool isDead, DateTime?birthDate, int?age) { Type = type; IsMale = isMale; FamilyMemberStatus = FamilyMemberStatusEnum.AliveAndFree; LifestyleTraits = new List <LifestyleTraitsEnum> { EnumExtensionMethod.Random <LifestyleTraitsEnum>() }; // randomly pick one if ((isDead) && (type != FamilyMemberTypeEnum.Father)) { BirthDate = null; Age = null; } else { if (birthDate == null) { BirthDate = gameDate.SubtractYears(age.GetValueOrDefault()); Age = age.GetValueOrDefault(); } else { BirthDate = birthDate.GetValueOrDefault(); Age = FamilyToolbox.DiffYears(BirthDate.GetValueOrDefault(), gameDate); } } if (string.IsNullOrWhiteSpace(forceSurname)) { Surname = CalcSurname(baseCity); // generate random one for focal person } else { Surname = forceSurname; // we want father's and siblings surnames to match focal person's } Name = CalcFirstName(baseCity, isMale) + " " + Surname; }
private void CreateFamilyOfChild(DateTime gameDate, City city, FamilyMember child, bool areDead, out FamilyMember father, out FamilyMember mother) { const bool isFatherDead = true; // SPECIAL - FOR GAME PURPOSES, I WANT ALWAYS TRUE. Applies to grandfathers as well. int? age = FamilyToolbox.CalcFathersAgeNow(child.Age.GetValueOrDefault()); father = new FamilyMember(CalcTypeForFather(child), city, true, gameDate, child.Surname, isFatherDead, null, age); AddFamilyMember(father); int?mothersAgeNow = areDead ? (int?)null : FamilyToolbox.CalcMothersAgeNow(child.Age.GetValueOrDefault()); mother = new FamilyMember(CalcTypeForMother(child), city, false, gameDate, null, areDead, null, mothersAgeNow); AddFamilyMember(mother); RelationshipXref parentSon = new RelationshipXref(RelationshipTypeEnum.BornOf, father, mother, child, null); AddRelationship(parentSon); if (!areDead) { // skip calculating marriage date of grandparents DateTime marriageDate = FamilyToolbox.CalcMarriageDate(gameDate, mothersAgeNow.GetValueOrDefault(), child.Age.GetValueOrDefault()); RelationshipXref parentsMarriage = new RelationshipXref(RelationshipTypeEnum.CurrentSpouseOf, father, mother, null, marriageDate); AddRelationship(parentsMarriage); } // Now add siblings int numSiblings = FamilyToolbox.CalcNumberOfSiblings(); if (numSiblings == 0) { if (child.Type == FamilyMemberTypeEnum.Father) { // SPECIAL - FOR GAME PURPOSES, I WANT AT LEAST 1 UNCLE. numSiblings = 1; } else { return; // abort since rest of code deals with siblings or aunts & uncles } } int paternalUncleCount = 0; List <FamilyMember> newFamilyMembers = new List <FamilyMember>(); for (int i = 0; i < numSiblings; i++) { // SPECIAL - FOR GAME PURPOSES, I WANT AT LEAST 1 PATERNAL UNCLE AND NO MATERNAL UNCLES. bool isMale = ((child.Type == FamilyMemberTypeEnum.Father) && (numSiblings == 1)) || FamilyToolbox.CalcIsMale(); FamilyMemberTypeEnum sibType = CalcTypeForSibling(child, isMale); // SPECIAL - FOR GAME PURPOSES, I WANT ONLY 1 PATERNAL UNCLE AND NO MATERNAL UNCLES. if (sibType == FamilyMemberTypeEnum.PaternalUncle) { paternalUncleCount++; if (paternalUncleCount > 1) { continue; // skip } } else if (sibType == FamilyMemberTypeEnum.MaternalUncle) { continue; // skip } FamilyMember sibling = new FamilyMember(sibType, city, isMale, gameDate, child.Surname, false, null, FamilyToolbox.CalcAgeOfSiblings(child.Age.GetValueOrDefault())); newFamilyMembers.Add(sibling); RelationshipXref siblingBirth = new RelationshipXref(RelationshipTypeEnum.BornOf, father, mother, sibling, null); AddRelationship(siblingBirth); } FamilyMembers.AddRange(newFamilyMembers.OrderByDescending(x => x.Age).ToList()); // sort by age so oldest is first }