Skip to content

Commit

Permalink
Updated OpFor Skill Generator and Added Skilled Level Parser
Browse files Browse the repository at this point in the history
Replaced `StratConSkillGenerator` with `ModifiedConstantSkillGenerator` in `AtBDynamicScenarioFactory`. Introduced skill level adjustments based on dice rolls and added a new method in `SkillLevel` to parse integer values to skill levels.
  • Loading branch information
IllianiCBT committed Sep 29, 2024
1 parent 72f857d commit 7489db0
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions megamek/src/megamek/common/enums/SkillLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
*/
package megamek.common.enums;

import megamek.MegaMek;
import megamek.logging.MMLogger;

import java.util.List;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import megamek.MegaMek;
import megamek.logging.MMLogger;

public enum SkillLevel {
// region Enum Declarations
NONE("SkillLevel.NONE.text", "SkillLevel.NONE.toolTipText"),
Expand Down Expand Up @@ -190,6 +190,29 @@ public static SkillLevel parseFromString(final String text) {

return REGULAR;
}

/**
* Parses an integer value to a {@link SkillLevel} enumeration.
*
* @param value the integer value to parse
* @return the {@link SkillLevel} enum corresponding to the given integer value
* @throws IllegalStateException if the integer value does not match any {@link SkillLevel} enum
* value
*/
public static SkillLevel parseFromInteger(final int value) {
return switch (value) {
case 0 -> NONE;
case 1 -> ULTRA_GREEN;
case 2 -> GREEN;
case 3 -> REGULAR;
case 4 -> VETERAN;
case 5 -> ELITE;
case 6 -> HEROIC;
case 7 -> LEGENDARY;
default -> throw new IllegalStateException(
"Unexpected value in megamek/common/enums/SkillLevel.java: " + value);
};
}
// endregion File I/O

@Override
Expand Down

0 comments on commit 7489db0

Please sign in to comment.