예제 #1
0
        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
        }
예제 #2
0
 private void AddRelationship(RelationshipXref relationship)
 {
     //Relationships.Add(relationship);
 }