From df68d7040e987d02439fa8c73698dfc9debadc55 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 17 Jun 2024 15:40:46 -0500 Subject: [PATCH 1/2] feat: Added education level assignment based on age in HireBulkPersonnelDialog and Campaign classes --- MekHQ/src/mekhq/campaign/Campaign.java | 6 ++++++ MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index 4b66245935..d8c8aa821e 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -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; } diff --git a/MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java b/MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java index e443dbce1d..5811180f8b 100644 --- a/MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java @@ -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; @@ -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 { From b9853ac587ecd2859b76bf59fbaf90c74823c00f Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 17 Jun 2024 15:48:23 -0500 Subject: [PATCH 2/2] feat(EducationController): added new school types and generation method - Added new school types to Education.properties - Added 'generateTypeChild' method to generate random educational institution type in EducationController.java - Updated 'generateName' method to handle PrepSchool type --- .../mekhq/resources/Education.properties | 3 ++ .../education/EducationController.java | 35 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/MekHQ/resources/mekhq/resources/Education.properties b/MekHQ/resources/mekhq/resources/Education.properties index 85cf74a19d..56416b13d1 100644 --- a/MekHQ/resources/mekhq/resources/Education.properties +++ b/MekHQ/resources/mekhq/resources/Education.properties @@ -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 diff --git a/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java b/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java index daafb53cdd..e5bd3b407b 100644 --- a/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java +++ b/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java @@ -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); @@ -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. *