From 7c69d3c116c1090fe5ae65aeb06d04c03afad0d4 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 19 Nov 2024 15:27:23 -0600 Subject: [PATCH] Removed Legacy AtB Guaranteed SPAs Removed hard-coded logic for SPA gain when improving personnel from Regular -> Veteran and Veteran -> Elite. --- .../DefaultSpecialAbilityGenerator.java | 40 --------------- .../adapter/PersonnelTableMouseAdapter.java | 25 --------- MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java | 51 ++++--------------- 3 files changed, 11 insertions(+), 105 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/personnel/generator/DefaultSpecialAbilityGenerator.java b/MekHQ/src/mekhq/campaign/personnel/generator/DefaultSpecialAbilityGenerator.java index de6e5911f5..af1619fce0 100644 --- a/MekHQ/src/mekhq/campaign/personnel/generator/DefaultSpecialAbilityGenerator.java +++ b/MekHQ/src/mekhq/campaign/personnel/generator/DefaultSpecialAbilityGenerator.java @@ -21,7 +21,6 @@ import mekhq.Utilities; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; public class DefaultSpecialAbilityGenerator extends AbstractSpecialAbilityGenerator { @Override @@ -41,45 +40,6 @@ public boolean generateSpecialAbilities(final Campaign campaign, final Person pe numAbilities--; } - // Based on the AtB rules, veteran recruits gain one and elite recruits gain two - // additional special abilities. Further, these are converted to edge if they - // cannot be - // generated. - if (campaign.getCampaignOptions().isUseAtB() && (expLvl >= SkillType.EXP_VETERAN)) { - // If we have more than 0 remaining abilities we can skip trying to generate - // after - // deciding on the number of further rolls and just convert it into edge - final boolean instantEdgeConversion = numAbilities != 0; - - // then we set the number of abilities to generate at 1 for veteran and 2 for - // elite - switch (expLvl) { - case SkillType.EXP_VETERAN: - numAbilities = 1; - break; - case SkillType.EXP_ELITE: - numAbilities = 2; - break; - } - - // If we aren't going to immediately convert into edge, we attempt to generate - // special - // abilities for the person - if (!instantEdgeConversion) { - while ((numAbilities > 0) - && singleSpecialAbilityGenerator.generateSpecialAbilities(campaign, person, expLvl)) { - numAbilities--; - } - } - - // If edge is enabled and there are any leftover abilities that cannot be - // generated - // we assign edge - if (campaign.getCampaignOptions().isUseEdge() && (instantEdgeConversion || (numAbilities > 0))) { - person.changeEdge(numAbilities); - } - } - return true; } diff --git a/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java b/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java index b4521be048..47d9f9d736 100644 --- a/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java +++ b/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java @@ -49,7 +49,6 @@ import mekhq.campaign.personnel.enums.*; import mekhq.campaign.personnel.enums.education.EducationLevel; import mekhq.campaign.personnel.enums.education.EducationStage; -import mekhq.campaign.personnel.generator.SingleSpecialAbilityGenerator; import mekhq.campaign.personnel.randomEvents.PersonalityController; import mekhq.campaign.personnel.ranks.Rank; import mekhq.campaign.personnel.ranks.RankSystem; @@ -480,30 +479,6 @@ public void actionPerformed(ActionEvent action) { gui.getCampaign().addReport(String.format(resources.getString("improved.format"), selectedPerson.getHyperlinkedName(), type)); - if (gui.getCampaign().getCampaignOptions().isUseAtB() - && gui.getCampaign().getCampaignOptions().isUseAbilities()) { - if (selectedPerson.getPrimaryRole().isCombat() - && (selectedPerson.getExperienceLevel(gui.getCampaign(), false) > oldExpLevel) - && (oldExpLevel >= SkillType.EXP_REGULAR)) { - SingleSpecialAbilityGenerator spaGenerator = new SingleSpecialAbilityGenerator(); - String spa = spaGenerator.rollSPA(gui.getCampaign(), selectedPerson); - if (spa == null) { - if (gui.getCampaign().getCampaignOptions().isUseEdge()) { - selectedPerson.changeEdge(1); - selectedPerson.changeCurrentEdge(1); - PersonalLogger.gainedEdge(gui.getCampaign(), selectedPerson, - gui.getCampaign().getLocalDate()); - gui.getCampaign().addReport(String.format(resources.getString("gainedEdge.format"), - selectedPerson.getHyperlinkedName())); - } - } else { - PersonalLogger.gainedSPA(gui.getCampaign(), selectedPerson, - gui.getCampaign().getLocalDate(), spa); - gui.getCampaign().addReport(String.format(resources.getString("gained.format"), - selectedPerson.getHyperlinkedName(), spa)); - } - } - } gui.getCampaign().personUpdated(selectedPerson); break; } diff --git a/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java b/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java index 7bca413ffa..6b69e9bf94 100644 --- a/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java @@ -18,26 +18,8 @@ */ package mekhq.gui.dialog; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.ResourceBundle; - -import javax.swing.*; -import javax.swing.RowSorter.SortKey; -import javax.swing.table.TableColumn; -import javax.swing.table.TableRowSorter; - import megamek.client.ui.models.XTableColumnModel; -import megamek.client.ui.preferences.JComboBoxPreference; -import megamek.client.ui.preferences.JIntNumberSpinnerPreference; -import megamek.client.ui.preferences.JToggleButtonPreference; -import megamek.client.ui.preferences.JWindowPreference; -import megamek.client.ui.preferences.PreferencesNode; +import megamek.client.ui.preferences.*; import megamek.codeUtilities.MathUtility; import megamek.common.enums.SkillLevel; import megamek.logging.MMLogger; @@ -49,13 +31,22 @@ import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.Skills; import mekhq.campaign.personnel.enums.PersonnelRole; -import mekhq.campaign.personnel.generator.SingleSpecialAbilityGenerator; import mekhq.campaign.personnel.ranks.Rank; import mekhq.gui.enums.PersonnelTableModelColumn; import mekhq.gui.model.PersonnelTableModel; import mekhq.gui.utilities.JScrollPaneWithSpeed; import mekhq.gui.utilities.MekHqTableCellRenderer; +import javax.swing.*; +import javax.swing.RowSorter.SortKey; +import javax.swing.table.TableColumn; +import javax.swing.table.TableRowSorter; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.ResourceBundle; + public final class BatchXPDialog extends JDialog { private static final MMLogger logger = MMLogger.create(BatchXPDialog.class); @@ -403,26 +394,6 @@ private void spendXP() { p.spendXP(cost); PersonalLogger.improvedSkill(campaign, p, campaign.getLocalDate(), p.getSkill(skillName).getType().getName(), p.getSkill(skillName).toString()); - - // The next part isn't ideal and doesn't belong here, but as long as we hardcode - // AtB ... - if (campaign.getCampaignOptions().isUseAtB()) { - if (p.getPrimaryRole().isCombat() && !p.getPrimaryRole().isVesselCrew() - && (p.getExperienceLevel(campaign, false) > startingExperienceLevel) - && (startingExperienceLevel >= SkillType.EXP_REGULAR)) { - final SingleSpecialAbilityGenerator spaGenerator = new SingleSpecialAbilityGenerator(); - final String spa = spaGenerator.rollSPA(campaign, p); - if (spa == null) { - if (campaign.getCampaignOptions().isUseEdge()) { - p.changeEdge(1); - p.changeCurrentEdge(1); - PersonalLogger.gainedEdge(campaign, p, campaign.getLocalDate()); - } - } else { - PersonalLogger.gainedSPA(campaign, p, campaign.getLocalDate(), spa); - } - } - } campaign.personUpdated(p); }