public Person(Person parent1, Person parent2, Date birthDate) : this(null) { _birthDate = birthDate; if (_random.NextDouble() < InfantMortality) { _healthStatuses.Clear(); _healthStatuses.Add(Health.Dead); } parent1.HaveChild(this); parent2.HaveChild(this); }
private void SetGrandchild(Person child) { RelationshipType myStatus = Gender == BaseTypes.Gender.Female ? RelationshipType.Grandmother : RelationshipType.Grandfather; RelationshipType childStatus = child.Gender == BaseTypes.Gender.Female ? RelationshipType.Granddaugther : RelationshipType.Grandson; _relationships.Add(new Relationship(child, myStatus)); child._relationships.Add(new Relationship(this, childStatus)); }
private void SetSibling(Person child) { RelationshipType myStatus = Gender == BaseTypes.Gender.Female ? RelationshipType.Sister : RelationshipType.Brother; RelationshipType childStatus = child.Gender == BaseTypes.Gender.Female ? RelationshipType.Sister : RelationshipType.Brother; _relationships.Add(new Relationship(child, myStatus)); child._relationships.Add(new Relationship(this, childStatus)); }
private void SetAuntUncle(Person child) { RelationshipType myStatus = Gender == BaseTypes.Gender.Female ? RelationshipType.Aunt : RelationshipType.Uncle; RelationshipType childStatus = child.Gender == BaseTypes.Gender.Female ? RelationshipType.Niece : RelationshipType.Nephew; _relationships.Add(new Relationship(child, myStatus)); child._relationships.Add(new Relationship(this, childStatus)); }
private bool IsFriendOf(Person person) { return _relationships.Any(r => r.Type == RelationshipType.Friend && r.To == person && r.Active); }
private bool IsEnemyOf(Person person) { return _relationships.Any(r => r.Type == RelationshipType.Enemy && r.To == person && r.Active); }
private void HaveChild(Person child) { RelationshipType myStatus = Gender == BaseTypes.Gender.Female ? RelationshipType.Mother : RelationshipType.Father; RelationshipType childStatus = child.Gender == BaseTypes.Gender.Female ? RelationshipType.Daughter : RelationshipType.Son; foreach (var p in GetChildren) { p.SetSibling(child); } foreach (var p in GetParents) { p.SetGrandchild(child); } foreach (var p in GetSiblings) { p.SetAuntUncle(child); foreach (var pc in p.GetChildren) { pc._relationships.Add(new Relationship(child, RelationshipType.Cousin)); child._relationships.Add(new Relationship(pc, RelationshipType.Cousin)); } } _relationships.Add(new Relationship(child, myStatus)); child._relationships.Add(new Relationship(this, childStatus)); }
public bool AreRelated(Person person) { foreach (var r in _relationships) { switch (r.Type) { case RelationshipType.Father: case RelationshipType.Mother: case RelationshipType.Son: case RelationshipType.Daughter: case RelationshipType.Brother: case RelationshipType.Sister: case RelationshipType.Grandfather: case RelationshipType.Grandmother: case RelationshipType.Grandson: case RelationshipType.Granddaugther: case RelationshipType.Uncle: case RelationshipType.Aunt: case RelationshipType.Niece: case RelationshipType.Nephew: case RelationshipType.Cousin: return true; } } return false; }