Skip to content

Commit

Permalink
Merge pull request #5867 from IllianiCBT/randomSPA
Browse files Browse the repository at this point in the history
Added GM Option to Assign Random SPAs
  • Loading branch information
IllianiCBT authored Jan 23, 2025
2 parents 01d696a + 73d0188 commit 150cdf9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ removePregnancy.text=Remove Pregnancy
removePregnancies.text=Remove Pregnancies
regenerateLoyalty.text=Regenerate Loyalty
regeneratePersonality.text=Regenerate Personality
addRandomSPA.text=Add Random SPA
addMinimumComplement.text=Add minimum complement
addMinimumComplementRandom.text=Random
addMinimumComplementElite.text=Elite
Expand Down
17 changes: 17 additions & 0 deletions MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
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;
Expand Down Expand Up @@ -143,6 +144,7 @@ public class PersonnelTableMouseAdapter extends JPopupMenuAdapter {
private static final String CMD_REMOVE_PREGNANCY = "PREGNANCY_SPOUSE";
private static final String CMD_LOYALTY = "LOYALTY";
private static final String CMD_PERSONALITY = "PERSONALITY";
private static final String CMD_ADD_RANDOM_ABILITY = "ADD_RANDOM_ABILITY";

private static final String CMD_IMPRISON = "IMPRISON";
private static final String CMD_FREE = "FREE";
Expand Down Expand Up @@ -1129,6 +1131,14 @@ public void actionPerformed(ActionEvent action) {
}
break;
}
case CMD_ADD_RANDOM_ABILITY: {
SingleSpecialAbilityGenerator singleSpecialAbilityGenerator = new SingleSpecialAbilityGenerator();
for (Person person : people) {
singleSpecialAbilityGenerator.rollSPA(gui.getCampaign(), person);
MekHQ.triggerEvent(new PersonChangedEvent(person));
}
break;
}

// region Randomization Menu
case CMD_RANDOM_NAME: {
Expand Down Expand Up @@ -3021,6 +3031,13 @@ protected Optional<JPopupMenu> createPopupMenu() {
menu.add(menuItem);
}

if (gui.getCampaign().getCampaignOptions().isUseAbilities()) {
menuItem = new JMenuItem(resources.getString("addRandomSPA.text"));
menuItem.setActionCommand(CMD_ADD_RANDOM_ABILITY);
menuItem.addActionListener(this);
menu.add(menuItem);
}

JMenuHelpers.addMenuIfNonEmpty(popup, menu);
}
// endregion GM Menu
Expand Down

0 comments on commit 150cdf9

Please sign in to comment.