@@ -72,8 +72,8 @@ public class SkillCheckUtility {
72
72
*/
73
73
protected static final int UNTRAINED_TARGET_NUMBER_TWO_LINKED_ATTRIBUTES = 18 ; // ATOW pg 43
74
74
75
- private Person person ;
76
- private String skillName ;
75
+ private final Person person ;
76
+ private final String skillName ;
77
77
private int marginOfSuccess ;
78
78
private String resultsText ;
79
79
private int targetNumber ;
@@ -89,22 +89,26 @@ public class SkillCheckUtility {
89
89
* <p><b>Usage:</b> This constructor gives you a lot of control over what information you need, but for most
90
90
* use-cases you can get away with using the lazy method: {@link #performQuickSkillCheck(Person, String)}.</p>
91
91
*
92
- * @param person the {@link Person} performing the skill check
93
- * @param skillName the name of the skill being used
94
- * @param useEdge whether the person should use edge for a re-roll if the first attempt fails
92
+ * @param person the {@link Person} performing the skill check
93
+ * @param skillName the name of the skill being used
94
+ * @param miscModifier any special modifiers, as an {@link Integer}. These values are subtracted from the target
95
+ * number, if the associated skill is classified as 'count up', otherwise they are added to the
96
+ * target number. This means negative values are bonuses, positive values are penalties.
97
+ * @param useEdge whether the person should use edge for a re-roll if the first attempt fails
95
98
*
96
99
* @author Illiani
97
100
* @since 0.50.5
98
101
*/
99
- public SkillCheckUtility (final Person person , final String skillName , final boolean useEdge ) {
102
+ public SkillCheckUtility (final Person person , final String skillName , final int miscModifier ,
103
+ final boolean useEdge ) {
100
104
this .person = person ;
101
105
this .skillName = skillName ;
102
106
103
107
if (isPersonNull ()) {
104
108
return ;
105
109
}
106
110
107
- targetNumber = determineTargetNumber (person , skillName );
111
+ targetNumber = determineTargetNumber (person , skillName , miscModifier );
108
112
performCheck (useEdge );
109
113
}
110
114
@@ -117,16 +121,19 @@ public SkillCheckUtility(final Person person, final String skillName, final bool
117
121
* <p><b>Usage:</b> This is a nice, quick lazy method for performing a skill check. For most use-cases across
118
122
* MekHQ this is the method you want to use. If you need more control use the class constructor, instead.</p>
119
123
*
120
- * @param person the {@link Person} performing the skill check
121
- * @param skillName the name of the skill being checked
124
+ * @param person the {@link Person} performing the skill check
125
+ * @param skillName the name of the skill being checked
126
+ * @param miscModifier any special modifiers, as an {@link Integer}. These values are subtracted from the target
127
+ * number, if the associated skill is classified as 'count up', otherwise they are added to the
128
+ * target number. This means negative values are bonuses, positive values are penalties.
122
129
*
123
130
* @return {@code true} if the skill check is successful, {@code false} otherwise
124
131
*
125
132
* @author Illiani
126
133
* @since 0.50.5
127
134
*/
128
- public static boolean performQuickSkillCheck (final Person person , final String skillName ) {
129
- SkillCheckUtility skillCheck = new SkillCheckUtility (person , skillName , false );
135
+ public static boolean performQuickSkillCheck (final Person person , final String skillName , final int miscModifier ) {
136
+ SkillCheckUtility skillCheck = new SkillCheckUtility (person , skillName , miscModifier , false );
130
137
return skillCheck .isSuccess ();
131
138
}
132
139
@@ -322,15 +329,18 @@ public boolean isUsedEdge() {
322
329
* <p>If the person is untrained, the target number is based on constants for untrained rolls and the number of
323
330
* linked attributes. Otherwise, it is based on the final skill value and attribute modifiers.</p>
324
331
*
325
- * @param person the {@link Person} performing the skill check
326
- * @param skillName the name of the skill being used
332
+ * @param person the {@link Person} performing the skill check
333
+ * @param skillName the name of the skill being used
334
+ * @param miscModifier any special modifiers, as an {@link Integer}. These values are subtracted from the target
335
+ * number, if the associated skill is classified as 'count up', otherwise they are added to the
336
+ * target number. This means negative values are bonuses, positive values are penalties.
327
337
*
328
338
* @return the target number for the skill check
329
339
*
330
340
* @author Illiani
331
341
* @since 0.50.5
332
342
*/
333
- static int determineTargetNumber (Person person , String skillName ) {
343
+ static int determineTargetNumber (Person person , String skillName , int miscModifier ) {
334
344
final SkillType skillType = SkillType .getType (skillName );
335
345
final Attributes characterAttributes = person .getATOWAttributes ();
336
346
@@ -356,8 +366,10 @@ static int determineTargetNumber(Person person, String skillName) {
356
366
357
367
targetNumber -= attributeModifier ;
358
368
if (skillType .isCountUp ()) {
369
+ targetNumber -= miscModifier ;
359
370
return min (targetNumber , COUNT_UP_MAX_VALUE );
360
371
} else {
372
+ targetNumber += miscModifier ;
361
373
return max (targetNumber , COUNT_DOWN_MIN_VALUE );
362
374
}
363
375
}
0 commit comments