for (Player player : playerService.getAllPlayers()) {
if (Gender.FEMALE.equals(player.getGender())
&& player.getAge() >= AGE_FOR_CHILDREN && !player.isDead()) {
if (marriageService.isMarried(player)) {
if (Math.random() < CHILDREN_PROBABILITY) {
Player husband = marriageService.getSpouse(player);
if (husband.getAge() >= AGE_FOR_CHILDREN
&& !husband.isDead()) {
Dynasty dynasty = playerService.getDynasty(husband);
Gender gender = Gender.random();
Player child = playerService
.generateNewPlayer(gender);
child.setFather(husband);
child.setMother(player);
child.setAge(0);
playerService.addPlayerToDynasty(dynasty, child);
messagingService
.addMessage(
null,
"A new child was born for " + husband.getName() //$NON-NLS-1$
+ " and " + player.getName() + ": " //$NON-NLS-1$ //$NON-NLS-2$
+ child.getName() + " of " //$NON-NLS-1$
+ dynasty.getName() + "."); //$NON-NLS-1$
}
}
}
}