private bool KillPersonOnRandomChance(IPerson person, IOdds odds) { if (!odds.OccuranceHappens()) { return(false); } AddToLogs($"Let us please mourn the passing of {person.Name}."); return(true); }
private Couple MarryPersonOnRandomChance(ICollection <Person> unmarried, Person person, IOdds odds) { var spouse = unmarried.FirstOrDefault(p => p != person && p.Gender != person.Gender); var marriageFailsToOccur = spouse == null || person.IsMarried || !person.IsAdult || !odds.OccuranceHappens(); if (marriageFailsToOccur) { return(null); } var newCouple = new Couple(person, spouse); unmarried.Remove(person); unmarried.Remove(spouse); AddToLogs($"Congratulations to newlyweds {person.Name} and {spouse.Name}."); return(newCouple); }
private bool PregnancyOccursOnRandomChanceForMarriedWomen(IPerson person, IOdds odds) { var isMarried = person.IsMarried && person.Spouse.IsAlive; var pregnancyFailsToOccur = person.IsMale || person.IsPregnant || !isMarried || !person.IsAdult || !odds.OccuranceHappens(); if (pregnancyFailsToOccur) { return(false); } AddToLogs($"{person.Name} became pregnant."); return(true); }