Skip to content

Commit 4c84bf0

Browse files
authored
Merge pull request #6561 from IllianiCBT/dedicatedSkillCheckClass
Added Dedicated Skill Check Class Utility
2 parents c3b6c3d + 1c9ea2d commit 4c84bf0

File tree

10 files changed

+2284
-766
lines changed

10 files changed

+2284
-766
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# suppress inspection "UnusedProperty" for the whole file
2+
SPECTACULAR.label=<i>Spectacular!</i>
3+
EXTRAORDINARY.label=<i>Extraordinary!</i>
4+
GOOD.label=<i>Good</i>
5+
IT_WILL_DO.label=<i>It'll do...</i>
6+
BARELY_MADE_IT.label=<i>Barely made it!</i>
7+
ALMOST.label=<i>Almost...</i>
8+
BAD.label=<i>Bad</i>
9+
TERRIBLE.label=<i>Terrible!</i>
10+
DISASTROUS.label=<i>Disastrous</i>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
skillCheck.results={0} {1}<b>failed</b>{2} {3} {4} check with a roll of <b>{5}</b> vs. a target number of <b>{6}</b>. {7}.{8}
2+
skillCheck.rerolled=\ {0} used a point of <b>Edge</b> when making this check.
3+
skillCheck.nullSkillName=ERROR: Skill name is null. Please report this bug to the MegaMek team.
4+
skillCheck.nullPerson=ERROR: Person is null. Please report this bug to the MegaMek team.

MekHQ/src/mekhq/campaign/personnel/skills/Attributes.java

+58
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import megamek.codeUtilities.MathUtility;
3535
import megamek.logging.MMLogger;
36+
import mekhq.campaign.personnel.skills.enums.SkillAttribute;
3637
import mekhq.utilities.MHQXMLUtility;
3738
import org.w3c.dom.Node;
3839
import org.w3c.dom.NodeList;
@@ -117,8 +118,65 @@ public Attributes() {
117118
charisma = DEFAULT_ATTRIBUTE_SCORE;
118119
}
119120

121+
/**
122+
* Constructs a new {@code Attributes} object with the specified attribute values.
123+
*
124+
* @param strength the {@link SkillAttribute#STRENGTH} value of the character, representing physical power.
125+
* @param body the {@link SkillAttribute#BODY} value of the character, representing endurance and physical
126+
* resilience.
127+
* @param reflexes the {@link SkillAttribute#REFLEXES} value of the character, representing reaction speed and
128+
* agility.
129+
* @param dexterity the {@link SkillAttribute#DEXTERITY} value of the character, representing skillfulness and
130+
* precision.
131+
* @param intelligence the {@link SkillAttribute#INTELLIGENCE} value of the character, representing cognitive
132+
* ability and reasoning.
133+
* @param willpower the {@link SkillAttribute#WILLPOWER} value of the character, representing mental strength and
134+
* determination.
135+
* @param charisma the {@link SkillAttribute#CHARISMA} value of the character, representing persuasiveness and
136+
* social skills.
137+
*
138+
* @author Illiani
139+
* @since 0.50.5
140+
*/
141+
public Attributes(int strength, int body, int reflexes, int dexterity, int intelligence, int willpower,
142+
int charisma) {
143+
this.strength = strength;
144+
this.body = body;
145+
this.reflexes = reflexes;
146+
this.dexterity = dexterity;
147+
this.intelligence = intelligence;
148+
this.willpower = willpower;
149+
this.charisma = charisma;
150+
}
151+
120152
// Getters and Setters
121153

154+
/**
155+
* Retrieves the value of a specified attribute.
156+
*
157+
* <p>This method returns the score of the requested {@link SkillAttribute}.
158+
* If the attribute does not match any of the defined attributes, the method returns {@code 0} as the default
159+
* value.</p>
160+
*
161+
* @param attribute the {@link SkillAttribute} to retrieve the value for.
162+
*
163+
* @return the value of the specified attribute, or {@code 0} if the attribute is not valid or not recognized.
164+
*
165+
* @since 0.50.05
166+
*/
167+
public int getAttribute(SkillAttribute attribute) {
168+
return switch (attribute) {
169+
case STRENGTH -> strength;
170+
case BODY -> body;
171+
case REFLEXES -> reflexes;
172+
case DEXTERITY -> dexterity;
173+
case INTELLIGENCE -> intelligence;
174+
case WILLPOWER -> willpower;
175+
case CHARISMA -> charisma;
176+
default -> 0;
177+
};
178+
}
179+
122180
/**
123181
* @return the current strength value.
124182
*

MekHQ/src/mekhq/campaign/personnel/skills/Skill.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@
6666
* <p>
6767
* target - this is the baseline target number for the skill when level and bonus are zero.
6868
* <p>
69-
* countUp - this is a boolean that defines whether this skill's target is a "roll greater than or equal to" (false) or
70-
* an rpg-style bonus to a roll (true)
69+
* isCountUp - this is a boolean that defines whether this skill's target is a "roll greater than or equal to" (false)
70+
* or an rpg-style bonus to a roll (true)
7171
* <p>
7272
* The actual target number for a skill is given by
7373
* <p>
74-
* countUp: target + lvl + bonus !countUp: target - level - bonus
74+
* isCountUp: target + lvl + bonus !isCountUp: target - level - bonus
7575
* <p>
7676
* by clever manipulation of these values and skill costs in campaignOptions, players should be able to recreate any of
7777
* the rpg versions or their own homebrew system. The default setup will follow the core rule books (not aToW).
7878
*
7979
* @author Jay Lawson (jaylawson39 at yahoo.com)
8080
*/
8181
public class Skill {
82-
private static int COUNT_UP_MAX_VALUE = 10;
83-
private static int COUNT_DOWN_MIN_VALUE = 0;
82+
public static int COUNT_UP_MAX_VALUE = 10;
83+
public static int COUNT_DOWN_MIN_VALUE = 0;
8484

8585
private static final MMLogger logger = MMLogger.create(Skill.class);
8686

@@ -137,7 +137,7 @@ public static int getCountDownMaxValue() {
137137
* @return {@code true} if the progression type is "count up", {@code false} otherwise.
138138
*/
139139
private boolean isCountUp() {
140-
return type.countUp();
140+
return type.isCountUp();
141141
}
142142

143143
/**

0 commit comments

Comments
 (0)