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

Corrected Errors in Post-Grad & Doctorate Graduation Handler #4564

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -975,10 +975,6 @@ private static boolean graduateAdult(Campaign campaign, Person person, Academy a

processGraduation(campaign, person, academy, 2, resources);

if (!academy.isMilitary()) {
reportMastersOrDoctorateGain(campaign, person, academy, resources);
}

person.setEduEducationStage(EducationStage.GRADUATING);

person.changeLoyalty(academy.getDurationDays() / 300);
Expand Down Expand Up @@ -1034,10 +1030,6 @@ private static boolean graduateAdult(Campaign campaign, Person person, Academy a

processGraduation(campaign, person, academy, 1, resources);

if (!academy.isMilitary()) {
reportMastersOrDoctorateGain(campaign, person, academy, resources);
}

person.setEduEducationStage(EducationStage.GRADUATING);

person.changeLoyalty(academy.getDurationDays() / 300);
Expand Down Expand Up @@ -1086,10 +1078,6 @@ private static boolean graduateAdult(Campaign campaign, Person person, Academy a

processGraduation(campaign, person, academy, 0, resources);

if (!academy.isMilitary()) {
reportMastersOrDoctorateGain(campaign, person, academy, resources);
}

person.setEduEducationStage(EducationStage.GRADUATING);

person.changeLoyalty(academy.getDurationDays() / 300);
Expand All @@ -1100,33 +1088,52 @@ private static boolean graduateAdult(Campaign campaign, Person person, Academy a
/**
* This method generates a report for individuals who have completed either a Master's or Doctorate degree.
*
* @param campaign the campaign to add the report to
* @param person the person who completed the degree
* @param resources the resource bundle containing localized strings
* @param campaign the campaign to add the report to
* @param person the person who completed the degree
* @param education the education level taught by the academy
* @param resources the resource bundle containing localized strings
*/
private static void reportMastersOrDoctorateGain(Campaign campaign, Person person, Academy academy, ResourceBundle resources) {
int education = academy.getEducationLevel(person) - 1; // we reduce by 1 to account for the +1 level from graduating

private static void reportMastersOrDoctorateGain(Campaign campaign, Person person, Academy academy,
int education, ResourceBundle resources) {
EducationLevel educationLevel = EducationLevel.parseFromInt(education);

String qualification = academy.getQualifications().get(person.getEduCourseIndex());
String personName = person.getHyperlinkedFullTitle();

String graduationLevel = "";

if (educationLevel.isPostGraduate()) {
graduationLevel = resources.getString("graduatedMasters.text");
ServiceLogger.eduGraduatedMasters(
person,
campaign.getLocalDate(),
person.getEduAcademyName(),
qualification
);

ServiceLogger.eduGraduatedMasters(person, campaign.getLocalDate(), person.getEduAcademyName(), qualification);
} else if (educationLevel.isDoctorate()) {
graduationLevel = resources.getString("graduatedDoctorate.text");
generatePostGradGraduationReport(
campaign,
personName,
resources.getString("graduatedMasters.text"),
qualification,
resources
);

ServiceLogger.eduGraduatedDoctorate(person, campaign.getLocalDate(), person.getEduAcademyName(), qualification);
} else if (educationLevel.isDoctorate()) {
ServiceLogger.eduGraduatedDoctorate(
person,
campaign.getLocalDate(),
person.getEduAcademyName(),
qualification
);

person.setPreNominal("Dr");
}

generatePostGradGraduationReport(campaign, personName, graduationLevel, qualification, resources);
generatePostGradGraduationReport(
campaign,
personName,
resources.getString("graduatedDoctorate.text"),
qualification,
resources
);
}
}

/**
Expand All @@ -1141,7 +1148,7 @@ private static void generatePostGradGraduationReport(Campaign campaign, String p
String graduationText, String qualification, ResourceBundle resources) {
campaign.addReport(String.format(resources.getString("graduatedPostGradReport.text"),
personName,
"<span color='" + MekHQ.getMHQOptions().getFontColorNegativeHexColor() + "'>",
"<span color='" + MekHQ.getMHQOptions().getFontColorPositiveHexColor() + "'>",
graduationText,
"</span>",
qualification));
Expand Down Expand Up @@ -1246,7 +1253,6 @@ private static void processGraduation(Campaign campaign, Person person, Academy
int educationLevel = academy.getEducationLevel(person);

if (EducationLevel.parseToInt(person.getEduHighestEducation()) < educationLevel) {
LogManager.getLogger().info(educationLevel);
person.setEduHighestEducation(EducationLevel.parseFromInt(educationLevel));
}

Expand All @@ -1268,6 +1274,10 @@ private static void processGraduation(Campaign campaign, Person person, Academy
} else {
adjustLoyalty(person);
}

if (!academy.isMilitary()) {
reportMastersOrDoctorateGain(campaign, person, academy, educationLevel, resources);
}
}

/**
Expand All @@ -1293,9 +1303,6 @@ private static void improveSkills(Campaign campaign, Person person, Academy acad
}

for (String skill : curriculum) {
LogManager.getLogger().info(skill);
LogManager.getLogger().info(educationLevel);

if (skill.equalsIgnoreCase("none")) {
return;
}
Expand Down