Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Child Education Level Handling & Academy Name Generation #4229

Merged
merged 5 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MekHQ/resources/mekhq/resources/Education.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ typeInstitute.text=Institute
typeUniversity.text=University
typePolytechnic.text=Polytechnic
typeSchool.text=School
typeSchoolBoarding.text=Boarding School
typeFinishingSchool.text=Finishing School
typePreparatorySchool.text=Preparatory School

#### Academy Suffix
suffixTechnology.text=Technology
Expand Down
6 changes: 6 additions & 0 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,12 @@ public Person newDependent(boolean baby) {
Gender.RANDOMIZE);
}

if (person.getAge(getLocalDate()) <= 16) {
person.setEduHighestEducation(EducationLevel.EARLY_CHILDHOOD);
} else {
person.setEduHighestEducation(EducationLevel.HIGH_SCHOOL);
}

return person;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ public static void enrollPerson(Campaign campaign, Person person, Academy academ
public static String generateName(Academy academy, String campus) {
ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.Education", MekHQ.getMHQOptions().getLocale());

if (academy.isPrepSchool()) {
if (Compute.d6(1) <= 3) {
return campus + ' ' + generateTypeChild(resources) + ' ' + resources.getString("conjoinerOf.text") + ' ' + generateSuffix(resources);
} else {
return generateTypeChild(resources) + ' ' + resources.getString("conjoinerOf.text") + ' ' + campus;
}
}

if (Compute.d6(1) <= 3) {
if (academy.isMilitary()) {
return campus + ' ' + generateMilitaryPrefix(resources) + ' ' + generateTypeAdult(resources) + ' ' + resources.getString("conjoinerOf.text") + ' ' + generateSuffix(resources);
Expand Down Expand Up @@ -239,6 +247,33 @@ private static String generateTypeAdult(ResourceBundle resources) {
}
}


/**
* Generates a random educational institution type from the provided ResourceBundle.
*
* @param resources the ResourceBundle containing the localized strings for the educational institution types
* @return a randomly selected educational institution type
* @throws IllegalStateException if the generated roll is unexpected
*/
private static String generateTypeChild(ResourceBundle resources) {
switch (Compute.d6(1)) {
case 1:
return resources.getString("typeAcademy.text");
case 2:
return resources.getString("typePreparatorySchool.text");
case 3:
return resources.getString("typeInstitute.text");
case 4:
return resources.getString("typeSchoolBoarding.text");
case 5:
return resources.getString("typeFinishingSchool.text");
case 6:
return resources.getString("typeSchool.text");
default:
throw new IllegalStateException("Unexpected roll in generateTypeAdult");
}
}

/**
* Processes a new day for a person in a campaign.
*
Expand Down
8 changes: 8 additions & 0 deletions MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import mekhq.campaign.personnel.Person;
import mekhq.campaign.personnel.enums.PersonnelRole;
import mekhq.campaign.personnel.enums.Profession;
import mekhq.campaign.personnel.enums.education.EducationLevel;
import mekhq.gui.CampaignGUI;
import mekhq.gui.displayWrappers.RankDisplay;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -357,6 +358,13 @@ private void hire(boolean isGmHire) {
person.limitSkills(age - 13);
}

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

if (!campaign.recruitPerson(person, isGmHire)) {
number = 0;
} else {
Expand Down
Loading