Skip to content

Commit

Permalink
Merge pull request #5240 from psikomonkie/issue-5239-simulated-relati…
Browse files Browse the repository at this point in the history
…onship-behavior-fixes

Issue 5239 simulated relationship behavior fixes
  • Loading branch information
IllianiCBT authored Nov 24, 2024
2 parents 3abd872 + f8c02c7 commit ae256a5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
32 changes: 18 additions & 14 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,8 @@ private void simulateRelationshipHistory(Person person) {

List<Person> children = new ArrayList<>();
Person currentSpouse = null;
Person babysFather = null;
Person spousesBabysFather = null;

// run the simulation
for (long weeksRemaining = weeksBetween; weeksRemaining >= 0; weeksRemaining--) {
Expand Down Expand Up @@ -1716,35 +1718,37 @@ private void simulateRelationshipHistory(Person person) {
}

// then we check for children
if (person.getGender().isFemale()) {
if ((person.getGender().isFemale()) && (!person.isPregnant())) {
getProcreation().processRandomProcreationCheck(this, localDate.minusWeeks(weeksRemaining), person, true);

if (person.isPregnant()) {

Person father = null;

if ((currentSpouse != null) && (currentSpouse.getGender().isMale())) {
father = currentSpouse;
babysFather = currentSpouse;
}

children.addAll(getProcreation().birthHistoric(this, person.getDueDate(), person, father));
}
}

if ((currentSpouse != null) && (currentSpouse.getGender().isFemale())) {
getProcreation().processRandomProcreationCheck(this, localDate.minusWeeks(weeksRemaining), person, true);

if (person.isPregnant()) {
if ((currentSpouse != null) && (currentSpouse.getGender().isFemale()) && (!currentSpouse.isPregnant())) {
getProcreation().processRandomProcreationCheck(this, localDate.minusWeeks(weeksRemaining), currentSpouse, true);

Person father = null;
if (currentSpouse.isPregnant()) {

if (person.getGender().isMale()) {
father = currentSpouse;
spousesBabysFather = person;
}

getProcreation().birthHistoric(this, person.getDueDate(), person, father);
}
}

if((person.isPregnant()) && (currentDate.isAfter(person.getDueDate()))) {
children.addAll(getProcreation().birthHistoric(this, localDate, person, babysFather));
babysFather = null;
}

if((currentSpouse != null) && (currentSpouse.isPregnant()) && (currentDate.isAfter(currentSpouse.getDueDate()))) {
children.addAll(getProcreation().birthHistoric(this, localDate, currentSpouse, spousesBabysFather));
spousesBabysFather = null;
}
}

// with the simulation concluded, we add the current spouse (if any) and any remaining children to the unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ public List<Person> birthHistoric(final Campaign campaign, final LocalDate today
baby.setSurname(campaign.getCampaignOptions().getBabySurnameStyle()
.generateBabySurname(mother, father, baby.getGender()));

baby.setDateOfBirth(today);// Limit skills by age for children and adolescents
baby.setDateOfBirth(mother.getDueDate());

baby.removeAllSkills();
baby.removeAllSkills();// Limit skills by age for children and adolescents

// re-roll SPAs to include in any age and skill adjustments
Enumeration<IOption> options = new PersonnelOptions().getOptions(PersonnelOptions.LVL3_ADVANTAGES);
Expand All @@ -466,7 +466,11 @@ public List<Person> birthHistoric(final Campaign campaign, final LocalDate today
baby.setLoyalty(Compute.d6(3) + 2);

// set education based on age
baby.setEduHighestEducation(EducationLevel.EARLY_CHILDHOOD);
if(baby.getAge(today) < 16) {
baby.setEduHighestEducation(EducationLevel.EARLY_CHILDHOOD);
} else {
baby.setEduHighestEducation(EducationLevel.HIGH_SCHOOL);
}

// Create reports and log the birth
logAndUpdateFamily(campaign, today, mother, baby, father);
Expand All @@ -475,6 +479,10 @@ public List<Person> birthHistoric(final Campaign campaign, final LocalDate today
babies.add(baby);
}

if (Compute.d6(1) <= 2) {
mother.setTryingToConceive(false);
}

// Cleanup Data
removePregnancy(mother);

Expand Down

0 comments on commit ae256a5

Please sign in to comment.