Skip to content

Commit

Permalink
Merge pull request #4257 from IllianiCBT/education_bonusXp
Browse files Browse the repository at this point in the history
Adjusted Curriculum XP to Use a Fixed Value Instead of Dynamic
  • Loading branch information
IllianiCBT authored Jun 21, 2024
2 parents 8fe6cf4 + 2c2873e commit d21fce2
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 20 deletions.
16 changes: 8 additions & 8 deletions MekHQ/data/universe/academies/Local Academies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<educationLevelMax>Early Childhood</educationLevelMax>
<ageMax>10</ageMax>
<qualification>General Education</qualification>
<curriculum>Bonus XP</curriculum>
<curriculum>XP</curriculum>
<qualificationStartYear>2300</qualificationStartYear>
<baseAcademicSkillLevel>1</baseAcademicSkillLevel>
</academy>
Expand All @@ -28,9 +28,9 @@
<ageMin>10</ageMin>
<ageMax>16</ageMax>
<qualification>General Education</qualification>
<curriculum>Bonus XP</curriculum>
<curriculum>XP</curriculum>
<qualificationStartYear>2300</qualificationStartYear>
<baseAcademicSkillLevel>1</baseAcademicSkillLevel>
<baseAcademicSkillLevel>0</baseAcademicSkillLevel>
</academy>
<academy>
<name>Preparatory School</name>
Expand All @@ -45,9 +45,9 @@
<ageMin>10</ageMin>
<ageMax>16</ageMax>
<qualification>General Education</qualification>
<curriculum>Bonus XP, Leadership</curriculum>
<curriculum>XP, Leadership</curriculum>
<qualificationStartYear>2300</qualificationStartYear>
<baseAcademicSkillLevel>1</baseAcademicSkillLevel>
<baseAcademicSkillLevel>0</baseAcademicSkillLevel>
</academy>
<academy>
<name>Military School</name>
Expand Down Expand Up @@ -105,9 +105,9 @@
<ageMin>16</ageMin>
<durationDays>150</durationDays>
<qualification>General Education</qualification>
<curriculum>Bonus XP</curriculum>
<curriculum>XP</curriculum>
<qualificationStartYear>2300</qualificationStartYear>
<baseAcademicSkillLevel>1</baseAcademicSkillLevel>
<baseAcademicSkillLevel>0</baseAcademicSkillLevel>
</academy>
<academy>
<name>Technical College</name>
Expand Down Expand Up @@ -229,7 +229,7 @@
<educationLevelMin>Early Childhood</educationLevelMin>
<educationLevelMax>Early Childhood</educationLevelMax>
<qualification>Reeducation &amp; Social Encouragement</qualification>
<curriculum>Bonus XP</curriculum>
<curriculum>XP</curriculum>
<qualificationStartYear>2300</qualificationStartYear>
<baseAcademicSkillLevel>1</baseAcademicSkillLevel>
</academy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ chkUseEducationModule.toolTip=Enables the Education Module.

lblMaximumJumpCount.text=Maximum Jump Radius
lblMaximumJumpCount.toolTip=The maximum distance when searching for academies.
lblCurriculumXpRate.text=Bonus XP Rate
lblCurriculumXpRate.toolTip=Some curriculum award bonus xp (outside monthly random xp). This setting determines how much XP should be gained per education level.
chkUseReeducationCamps.text=Enable Reeducation Camp Faction Change
chkUseReeducationCamps.toolTip=Should reeducation camps change a students' origin faction to match the campaign faction?
chkShowIneligibleAcademies.text=Show Ineligible Academies
Expand Down
3 changes: 1 addition & 2 deletions MekHQ/resources/mekhq/resources/Education.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#### Tooltip Builder
curriculum.text=Curriculum:
educationLevel.text=Education Level:
xpBonus.text=d6
nothingToLearn.text=nothing to learn
tuition.text=Tuition:
duration.text=Duration:
Expand Down Expand Up @@ -76,7 +75,7 @@ graduatedMasters.text=has completed their Master's Degree.
graduatedDoctorate.text=has completed their Doctorate.
bonusAdded.text=During their education or training, %s discovered a natural talent!
bonusXp.text=%s learned something new (+%s XP)
graduatedChild.text=has graduated from %s. Tomorrow, they will begin their journey back to the unit.
graduatedChild.text=graduated from %s. Tomorrow, they will begin their journey back to the unit.

#### Graduation Events (positive)
addressEncouragement.text=during which, the commencement address included words of encouragement
Expand Down
13 changes: 13 additions & 0 deletions MekHQ/src/mekhq/campaign/CampaignOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ public static String getTransitUnitName(final int unit) {

// Education
private boolean useEducationModule;
private Integer curriculumXpRate;
private Integer maximumJumpCount;
private boolean useReeducationCamps;
private boolean enableLocalAcademies;
Expand Down Expand Up @@ -894,6 +895,7 @@ public CampaignOptions() {

// Education
setUseEducationModule(true);
setCurriculumXpRate(3);
setMaximumJumpCount(5);
setUseReeducationCamps(true);
setEnableLocalAcademies(true);
Expand Down Expand Up @@ -2689,6 +2691,14 @@ public void setUseEducationModule(boolean useEducationModule) {
this.useEducationModule = useEducationModule;
}

public Integer getCurriculumXpRate() {
return curriculumXpRate;
}

public void setCurriculumXpRate(final int curriculumXpRate) {
this.curriculumXpRate = curriculumXpRate;
}

public Integer getMaximumJumpCount() {
return maximumJumpCount;
}
Expand Down Expand Up @@ -4729,6 +4739,7 @@ public void writeToXml(final PrintWriter pw, int indent) {

//region Education
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "useEducationModule", isUseEducationModule());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "curriculumXpRate", getCurriculumXpRate());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "maximumJumpCount", getMaximumJumpCount());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "useReeducationCamps", isUseReeducationCamps());
MHQXMLUtility.writeSimpleXMLTag(pw, indent, "enableLocalAcademies", isEnableLocalAcademies());
Expand Down Expand Up @@ -5478,6 +5489,8 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve
//region Education
} else if (wn2.getNodeName().equalsIgnoreCase("useEducationModule")) {
retVal.setUseEducationModule(Boolean.parseBoolean(wn2.getTextContent().trim()));
} else if (wn2.getNodeName().equalsIgnoreCase("curriculumXpRate")) {
retVal.setCurriculumXpRate(Integer.parseInt(wn2.getTextContent().trim()));
} else if (wn2.getNodeName().equalsIgnoreCase("maximumJumpCount")) {
retVal.setMaximumJumpCount(Integer.parseInt(wn2.getTextContent().trim()));
} else if (wn2.getNodeName().equalsIgnoreCase("useReeducationCamps")) {
Expand Down
4 changes: 2 additions & 2 deletions MekHQ/src/mekhq/campaign/personnel/education/Academy.java
Original file line number Diff line number Diff line change
Expand Up @@ -872,11 +872,11 @@ public String getTooltip(Campaign campaign, List<Person> personnel, int courseIn
for (String skill : skills) {
tooltip.append(skill).append(" (");

if (skill.equalsIgnoreCase("xp bonus") || (skill.equalsIgnoreCase("bonus xp"))) {
if (skill.equalsIgnoreCase("xp")) {
if (EducationLevel.parseToInt(person.getEduHighestEducation()) >= educationLevel) {
tooltip.append(resources.getString("nothingToLearn.text")).append(")<br>");
} else {
tooltip.append(educationLevel).append(resources.getString("xpBonus.text")).append(")<br>");
tooltip.append(educationLevel * campaign.getCampaignOptions().getCurriculumXpRate()).append(")<br>");
}
} else {
String skillParsed = skillParser(skill);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,8 @@ private static void improveSkills(Campaign campaign, Person person, Academy acad
}

for (String skill : curriculum) {
if (skill.equalsIgnoreCase("bonus xp")) {
person.awardXP(campaign, Compute.d6(Math.max(1, educationLevel)));
if (skill.equalsIgnoreCase("xp")) {
person.awardXP(campaign, educationLevel * campaign.getCampaignOptions().getCurriculumXpRate());
} else {
String skillParsed = Academy.skillParser(skill);
int bonus;
Expand Down Expand Up @@ -940,18 +940,17 @@ private static void addBonus(Campaign campaign, Person person, Academy academy,
campaign.addReport(String.format(resources.getString("bonusAdded.text"),
person.getFirstName()));
} else {
roll = Compute.d6(2);
person.awardXP(campaign, roll);
person.awardXP(campaign, campaign.getCampaignOptions().getCurriculumXpRate());

campaign.addReport(String.format(resources.getString("bonusXp.text"),
person.getFirstName(), roll));
person.getFirstName(), campaign.getCampaignOptions().getCurriculumXpRate()));
}
} catch (Exception e) {
// if we get this, it means the 'skill' was Bonus XP
person.awardXP(campaign, Compute.d6(2));
// if we get this, it means the 'skill' was XP
person.awardXP(campaign, campaign.getCampaignOptions().getCurriculumXpRate());

campaign.addReport(String.format(resources.getString("bonusXp.text"),
person.getFirstName(), roll));
person.getFirstName(), campaign.getCampaignOptions().getCurriculumXpRate()));
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ public class CampaignOptionsPane extends AbstractMHQTabbedPane {

// Education
private JCheckBox chkUseEducationModule;
private JLabel lblCurriculumXpRate;
private JSpinner spnCurriculumXpRate;
private JLabel lblMaximumJumpCount;
private JSpinner spnMaximumJumpCount;
private JCheckBox chkUseReeducationCamps;
Expand Down Expand Up @@ -6042,6 +6044,14 @@ public Component getListCellRendererComponent(final JList<?> list, final Object

private JPanel createEducationPanel() {
// General Settings
lblCurriculumXpRate = new JLabel(resources.getString("lblCurriculumXpRate.text"));
lblCurriculumXpRate.setToolTipText(resources.getString("lblCurriculumXpRate.toolTip"));
lblCurriculumXpRate.setName("lblCurriculumXpRate");

spnCurriculumXpRate = new JSpinner(new SpinnerNumberModel(3, 1, 10, 1));
spnCurriculumXpRate.setToolTipText(resources.getString("lblCurriculumXpRate.toolTip"));
spnCurriculumXpRate.setName("spnCurriculumXpRate");

lblMaximumJumpCount = new JLabel(resources.getString("lblMaximumJumpCount.text"));
lblMaximumJumpCount.setToolTipText(resources.getString("lblMaximumJumpCount.toolTip"));
lblMaximumJumpCount.setName("lblMaximumJumpCount");
Expand Down Expand Up @@ -6088,6 +6098,8 @@ private JPanel createEducationPanel() {
chkUseEducationModule.addActionListener(evt -> {
final boolean isEnabled = chkUseEducationModule.isSelected();

lblCurriculumXpRate.setEnabled(isEnabled);
spnCurriculumXpRate.setEnabled(isEnabled);
lblMaximumJumpCount.setEnabled(isEnabled);
spnMaximumJumpCount.setEnabled(isEnabled);
chkUseReeducationCamps.setEnabled(isEnabled);
Expand Down Expand Up @@ -6123,6 +6135,8 @@ private JPanel createEducationPanel() {

// this prevents a really annoying bug where disabled options don't stay disabled when
// reloading Campaign Options
lblCurriculumXpRate.setEnabled(campaign.getCampaignOptions().isUseEducationModule());
spnCurriculumXpRate.setEnabled(campaign.getCampaignOptions().isUseEducationModule());
lblMaximumJumpCount.setEnabled(campaign.getCampaignOptions().isUseEducationModule());
spnMaximumJumpCount.setEnabled(campaign.getCampaignOptions().isUseEducationModule());
chkUseReeducationCamps.setEnabled(campaign.getCampaignOptions().isUseEducationModule());
Expand All @@ -6147,6 +6161,9 @@ private JPanel createEducationPanel() {
layout.createSequentialGroup()
.addComponent(chkUseEducationModule)
.addGap(10)
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(lblCurriculumXpRate)
.addComponent(spnCurriculumXpRate))
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(lblMaximumJumpCount)
.addComponent(spnMaximumJumpCount))
Expand All @@ -6163,6 +6180,9 @@ private JPanel createEducationPanel() {
layout.createParallelGroup(Alignment.LEADING)
.addComponent(chkUseEducationModule)
.addGap(10)
.addGroup(layout.createSequentialGroup()
.addComponent(lblCurriculumXpRate)
.addComponent(spnCurriculumXpRate))
.addGroup(layout.createSequentialGroup()
.addComponent(lblMaximumJumpCount)
.addComponent(spnMaximumJumpCount))
Expand Down Expand Up @@ -8212,6 +8232,7 @@ public void setOptions(@Nullable CampaignOptions options,

// Education
chkUseEducationModule.setSelected(options.isUseEducationModule());
spnCurriculumXpRate.setValue(options.getCurriculumXpRate());
spnMaximumJumpCount.setValue(options.getMaximumJumpCount());
chkUseReeducationCamps.setSelected(options.isUseReeducationCamps());
chkEnableLocalAcademies.setSelected(options.isEnableLocalAcademies());
Expand Down Expand Up @@ -8877,6 +8898,7 @@ public void updateOptions() {

// Education
options.setUseEducationModule(chkUseEducationModule.isSelected());
options.setCurriculumXpRate((Integer) spnCurriculumXpRate.getValue());
options.setMaximumJumpCount((Integer) spnMaximumJumpCount.getValue());
options.setUseReeducationCamps(chkUseReeducationCamps.isSelected());
options.setEnableLocalAcademies(chkEnableLocalAcademies.isSelected());
Expand Down

0 comments on commit d21fce2

Please sign in to comment.