From 7489db0182533208f04cf4f7083a708475fe6446 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sat, 28 Sep 2024 19:03:36 -0500 Subject: [PATCH] Updated OpFor Skill Generator and Added Skilled Level Parser 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. --- .../src/megamek/common/enums/SkillLevel.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/megamek/src/megamek/common/enums/SkillLevel.java b/megamek/src/megamek/common/enums/SkillLevel.java index d6eac78ceb..c1a840006e 100644 --- a/megamek/src/megamek/common/enums/SkillLevel.java +++ b/megamek/src/megamek/common/enums/SkillLevel.java @@ -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"), @@ -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