Skip to content

Commit 65fa418

Browse files
authored
Merge pull request #6539 from IllianiCBT/flawsGlassJaw
Added "Glass Jaw" SPA
2 parents 89ad5a9 + 6584d80 commit 65fa418

File tree

9 files changed

+910
-807
lines changed

9 files changed

+910
-807
lines changed

MekHQ/data/universe/defaultspa.xml

+8
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,14 @@
464464
</ability>
465465

466466
<!-- Misc SPA -->
467+
<ability>
468+
<lookupName>flaw_glass_jaw</lookupName>
469+
<displayName>Glass Jaw (ATOW)</displayName>
470+
<desc>All injuries suffered and fatigue gained is doubled</desc>
471+
<xpCost>-300</xpCost>
472+
<weight>1</weight>
473+
<skillPrereq/>
474+
</ability>
467475
<ability>
468476
<lookupName>eagle_eyes</lookupName>
469477
<xpCost>100</xpCost>

MekHQ/src/mekhq/campaign/ResolveScenarioTracker.java

+211-144
Large diffs are not rendered by default.

MekHQ/src/mekhq/campaign/personnel/Person.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import static megamek.codeUtilities.MathUtility.clamp;
3434
import static megamek.common.Compute.randomInt;
3535
import static megamek.common.enums.SkillLevel.REGULAR;
36+
import static mekhq.campaign.personnel.enums.BloodGroup.getRandomBloodGroup;
3637
import static mekhq.campaign.personnel.skills.SkillType.S_ADMIN;
3738
import static mekhq.campaign.personnel.enums.BloodGroup.getRandomBloodGroup;
3839
import static mekhq.campaign.personnel.skills.SkillType.S_ADMIN;
@@ -337,7 +338,7 @@ public Person(final String givenName, final String surname, final Campaign campa
337338
}
338339

339340
public Person(final String givenName, final String surname, final @Nullable Campaign campaign,
340-
final String factionCode) {
341+
final String factionCode) {
341342
this("", givenName, surname, "", campaign, factionCode);
342343
}
343344

@@ -352,7 +353,7 @@ public Person(final String givenName, final String surname, final @Nullable Camp
352353
* @param factionCode the faction this person was borne into
353354
*/
354355
public Person(final String preNominal, final String givenName, final String surname, final String postNominal,
355-
final @Nullable Campaign campaign, final String factionCode) {
356+
final @Nullable Campaign campaign, final String factionCode) {
356357
// We assign the variables in XML file order
357358
id = UUID.randomUUID();
358359

@@ -1294,7 +1295,7 @@ public void performRandomizedLoyaltyChange(Campaign campaign, boolean isMajor, b
12941295
* @param isVerbose a boolean indicating whether the method should generate a report if the loyalty has changed
12951296
*/
12961297
public void performForcedDirectionLoyaltyChange(Campaign campaign, boolean isPositive, boolean isMajor,
1297-
boolean isVerbose) {
1298+
boolean isVerbose) {
12981299
int originalLoyalty = loyalty;
12991300

13001301
Consumer<Integer> applyLoyaltyChange = (roll) -> {

MekHQ/src/mekhq/campaign/personnel/PersonnelOptions.java

+24-24
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,24 @@
2727
*/
2828
package mekhq.campaign.personnel;
2929

30-
import megamek.common.annotations.Nullable;
31-
import megamek.common.options.*;
32-
import megamek.logging.MMLogger;
33-
3430
import java.util.Enumeration;
3531
import java.util.Hashtable;
3632
import java.util.List;
3733
import java.util.Vector;
3834

35+
import megamek.common.annotations.Nullable;
36+
import megamek.common.options.AbstractOptionsInfo;
37+
import megamek.common.options.IBasicOptionGroup;
38+
import megamek.common.options.IOption;
39+
import megamek.common.options.IOptionGroup;
40+
import megamek.common.options.IOptionInfo;
41+
import megamek.common.options.OptionsConstants;
42+
import megamek.common.options.PilotOptions;
43+
import megamek.logging.MMLogger;
44+
3945
/**
40-
* An extension of PilotOptions that adds MekHQ-specific SPAs and edge triggers
41-
* for support and command
42-
* actions. Display names and descriptions are taken from SpecialAbility when
43-
* present, otherwise
44-
* from the MM option.
46+
* An extension of PilotOptions that adds MekHQ-specific SPAs and edge triggers for support and command actions. Display
47+
* names and descriptions are taken from SpecialAbility when present, otherwise from the MM option.
4548
*
4649
* @author Neoancient
4750
*/
@@ -59,6 +62,7 @@ public class PersonnelOptions extends PilotOptions {
5962
public static final String TECH_ENGINEER = "tech_engineer";
6063
public static final String TECH_FIXER = "tech_fixer";
6164
public static final String TECH_MAINTAINER = "tech_maintainer";
65+
public static final String FLAW_GLASS_JAW = "flaw_glass_jaw";
6266

6367
@Override
6468
public void initialize() {
@@ -67,7 +71,7 @@ public void initialize() {
6771
IBasicOptionGroup l3a = null;
6872
IBasicOptionGroup edge = null;
6973
IBasicOptionGroup md = null;
70-
for (Enumeration<IBasicOptionGroup> e = getOptionsInfoImp().getGroups(); e.hasMoreElements();) {
74+
for (Enumeration<IBasicOptionGroup> e = getOptionsInfoImp().getGroups(); e.hasMoreElements(); ) {
7175
final IBasicOptionGroup group = e.nextElement();
7276
if ((null == l3a) && group.getKey().equals(PilotOptions.LVL3_ADVANTAGES)) {
7377
l3a = group;
@@ -102,6 +106,7 @@ public void initialize() {
102106
addOption(l3a, TECH_ENGINEER, false);
103107
addOption(l3a, TECH_FIXER, false);
104108
addOption(l3a, TECH_MAINTAINER, false);
109+
addOption(l3a, FLAW_GLASS_JAW, false);
105110

106111
addOption(edge, EDGE_MEDICAL, true);
107112
addOption(edge, EDGE_REPAIR_BREAK_PART, true);
@@ -122,8 +127,8 @@ public void initialize() {
122127
break;
123128
default:
124129
throw new IllegalStateException(
125-
"Unexpected value in mekhq/campaign/personnel/PersonnelOptions.java/initialize: "
126-
+ option.getGroup());
130+
"Unexpected value in mekhq/campaign/personnel/PersonnelOptions.java/initialize: " +
131+
option.getGroup());
127132
}
128133
}
129134
}
@@ -143,7 +148,7 @@ protected void addOption(IBasicOptionGroup group, String name, int type, Object
143148
* Returns the options of the given category that this pilot has
144149
*/
145150
public Enumeration<IOption> getOptions(String grpKey) {
146-
for (Enumeration<IOptionGroup> i = getGroups(); i.hasMoreElements();) {
151+
for (Enumeration<IOptionGroup> i = getGroups(); i.hasMoreElements(); ) {
147152
IOptionGroup group = i.nextElement();
148153

149154
if (group.getKey().equalsIgnoreCase(grpKey)) {
@@ -165,7 +170,7 @@ public void acquireAbility(final String type, final String name, final @Nullable
165170
if (null != spa) {
166171
toRemove = spa.getRemovedAbilities();
167172
}
168-
for (Enumeration<IOption> i = getOptions(type); i.hasMoreElements();) {
173+
for (Enumeration<IOption> i = getOptions(type); i.hasMoreElements(); ) {
169174
IOption ability = i.nextElement();
170175
if (ability.getName().equals(name)) {
171176
ability.setValue(value);
@@ -185,11 +190,9 @@ protected AbstractOptionsInfo getOptionsInfoImp() {
185190
}
186191

187192
/**
188-
* Custom IOptionsInfo class that allows adding additional options to the base
189-
* MegaMek
190-
* options before finalizing and also holds a hash of IOptionInfo objects for
191-
* the abilities
192-
* so we can provide names and descriptions for the MekHQ-specific options.
193+
* Custom IOptionsInfo class that allows adding additional options to the base MegaMek options before finalizing and
194+
* also holds a hash of IOptionInfo objects for the abilities so we can provide names and descriptions for the
195+
* MekHQ-specific options.
193196
*
194197
* @author Neoancient
195198
*/
@@ -224,11 +227,8 @@ private void setOptionInfo(String name) {
224227
}
225228

226229
/**
227-
* Access to ability names and descriptions from <code>SpecialAbility</code> if
228-
* the ability
229-
* has an entry, otherwise checks for the ability the MM PilotOptions class. If
230-
* not found
231-
* in either place, returns the lookup key instead.
230+
* Access to ability names and descriptions from <code>SpecialAbility</code> if the ability has an entry, otherwise
231+
* checks for the ability the MM PilotOptions class. If not found in either place, returns the lookup key instead.
232232
*
233233
* @author Neoancient
234234
*/

MekHQ/src/mekhq/campaign/personnel/education/TrainingCombatTeams.java

+6-11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
package mekhq.campaign.personnel.education;
2929

3030
import static java.lang.Math.round;
31+
import static mekhq.campaign.personnel.PersonnelOptions.FLAW_GLASS_JAW;
3132
import static mekhq.campaign.personnel.skills.SkillType.EXP_GREEN;
3233
import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG;
3334
import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor;
@@ -76,14 +77,6 @@ public class TrainingCombatTeams {
7677
private static final String BUNDLE_NAME = "mekhq.resources.Education";
7778
private static ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME, MekHQ.getMHQOptions().getLocale());
7879

79-
/**
80-
* Represents the fatigue gained by combat team members during training.
81-
*
82-
* <p>This is currently set to 3 which, when factoring in fatigue recovery, will result in a
83-
* gain of 2 Fatigue per week.</p>
84-
*/
85-
private final static int FATIGUE_GAIN = 2;
86-
8780
/**
8881
* Processes all training combat teams in the campaign.
8982
*
@@ -167,7 +160,7 @@ private static void processTraining(final Campaign campaign, final CombatTeam co
167160
* @param educatorSkills a map of skills and their experience levels available for teaching
168161
*/
169162
private static void performTraining(Campaign campaign, Force force, Person commander,
170-
Map<String, Integer> educatorSkills) {
163+
Map<String, Integer> educatorSkills) {
171164
for (UUID unitId : force.getAllUnits(true)) {
172165
Unit unit = campaign.getUnit(unitId);
173166

@@ -177,8 +170,10 @@ private static void performTraining(Campaign campaign, Force force, Person comma
177170

178171
for (Person trainee : unit.getActiveCrew()) {
179172
if (campaign.getCampaignOptions().isUseFatigue()) {
173+
int fatigueChangeRate = campaign.getCampaignOptions().getFatigueRate();
174+
boolean hasGlassJaw = trainee.getOptions().booleanOption(FLAW_GLASS_JAW);
180175

181-
trainee.changeFatigue(FATIGUE_GAIN);
176+
trainee.changeFatigue(fatigueChangeRate * (hasGlassJaw ? 4 : 2));
182177
}
183178

184179
if (commander.getUnit().getActiveCrew().contains(trainee)) {
@@ -235,7 +230,7 @@ private static void performTraining(Campaign campaign, Force force, Person comma
235230
* @param skillsBeingTrained a list of eligible {@link Skill} objects for training
236231
*/
237232
private static void processEducationTime(Campaign campaign, Person commander, Person trainee,
238-
List<Skill> skillsBeingTrained) {
233+
List<Skill> skillsBeingTrained) {
239234
final CampaignOptions campaignOptions = campaign.getCampaignOptions();
240235
final String EDUCATION_STRING = "TRAINING_COMBAT_TEAM"; // Never change this
241236
final int WEEK_DURATION = 7; // days

0 commit comments

Comments
 (0)