public static string KeyMarriedParents(PersonWithMetadata father, PersonWithMetadata mother) { var pc = new ParentRelationshipSearch(); pc.Mother = new RelationshipSearch { IsLookingForAgeQuant = mother.AgeQuants, IsLookingForFemale = mother.IsFemale }; pc.Father = new RelationshipSearch() { IsLookingForAgeQuant = father.AgeQuants, IsLookingForFemale = father.IsFemale }; pc.Married = true; return(pc.KeyParents()); }
private bool SetCouple(ParentRelationshipSearch next, PersonWithMetadata child, Func <ParentRelationshipSearch, PersonWithMetadata, Randomizer, Couple> getNewCouple, Randomizer randy) { var couple = GetFromCache(next.KeyParents()) ?? getNewCouple(next, child, randy); if (couple == null) { return(false); } SetNins(couple.FatherNin, couple.MotherNin, child); if (randy.Hit(NameModel.PHasSamesirnameAsParents(child))) { var takeFathers = couple.FatherSn != null && randy.Hit(50); child.Person.Sn = takeFathers ? couple.FatherSn : (couple.MotherSn ?? child.Person.Sn); } return(true); }
private Couple GetNewCouple(ParentRelationshipSearch next, PersonWithMetadata child, Randomizer randy) { var mother = next.Mother == null ? null : (GetParentNinFromCache(next.Mother) ?? GetNewParent(next.Mother, married: false)); var father = next.Father == null ? null : (GetParentNinFromCache(next.Father, mother) ?? GetNewParent(next.Father, married: false)); if (mother == null && father == null) { return(null); } var howManyChildrenTogether = GetNumberOfChildsTogether(mother?.RemainingNumberOfChildren, father?.RemainingNumberOfChildren, randy); int?beforeFather = father?.RemainingNumberOfChildren; int?beforeMother = mother?.RemainingNumberOfChildren; //usikker på om dette er mulig .. if (mother != null) { mother.RemainingNumberOfChildren = mother.RemainingNumberOfChildren - howManyChildrenTogether; } if (father != null) { father.RemainingNumberOfChildren = father.RemainingNumberOfChildren - howManyChildrenTogether; } var couple = new Couple { FatherNin = father?.Nin, MotherNin = mother?.Nin, FatherSn = father?.Sn, MotherSn = mother?.Sn, RemainingNumberOfChildren = howManyChildrenTogether - 1 }; AddToCoupleCache(couple, next.KeyParents()); return(couple); }