|
33 | 33 |
|
34 | 34 | import megamek.codeUtilities.MathUtility;
|
35 | 35 | import megamek.logging.MMLogger;
|
| 36 | +import mekhq.campaign.personnel.skills.enums.SkillAttribute; |
36 | 37 | import mekhq.utilities.MHQXMLUtility;
|
37 | 38 | import org.w3c.dom.Node;
|
38 | 39 | import org.w3c.dom.NodeList;
|
@@ -117,8 +118,65 @@ public Attributes() {
|
117 | 118 | charisma = DEFAULT_ATTRIBUTE_SCORE;
|
118 | 119 | }
|
119 | 120 |
|
| 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 | + |
120 | 152 | // Getters and Setters
|
121 | 153 |
|
| 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 | + |
122 | 180 | /**
|
123 | 181 | * @return the current strength value.
|
124 | 182 | *
|
|
0 commit comments