diff --git a/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java b/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java deleted file mode 100644 index 69a088dbb44..00000000000 --- a/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2024 - The MegaMek Team. All Rights Reserved. - * - * This file is part of MegaMek. - * - * MegaMek is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * MegaMek is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with MegaMek. If not, see . - */ -package megamek.client.generator.skillGenerators; - -import megamek.common.Compute; -import megamek.common.Entity; -import megamek.common.LandAirMek; - -public class StratConSkillGenerator extends TotalWarfareSkillGenerator { - /** - * Generates random skills based on the given entity and parameters. - * - * @param entity The entity for which skills need to be generated. - * @param clanPilot Determines if the entity is a clan pilot. - * @param forceClan Determines if the force is clan. - * @return An array of randomly generated skills based on the entity and parameters. - */ - @Override - public int[] generateRandomSkills(final Entity entity, final boolean clanPilot, final boolean forceClan) { - int skillLevel = switch (getLevel()) { - case ULTRA_GREEN -> 2; - case GREEN -> 3; - case VETERAN -> 5; - case ELITE -> 6; - case HEROIC -> 7; - case LEGENDARY -> 8; - default -> 4; // Regular - }; - - if (entity instanceof LandAirMek) { - skillLevel += 1; - } - - int roll = Compute.d6(1); - - if (roll == 1) { - skillLevel--; - } else if (roll == 6) { - skillLevel++; - } - - skillLevel += determineBonus(entity, clanPilot, forceClan); - - return cleanReturn(entity, - SKILL_LEVELS[0][Math.min(skillLevel, SKILL_LEVELS[0].length)], - SKILL_LEVELS[1][Math.min(skillLevel, SKILL_LEVELS[1].length)]); - } -} diff --git a/megamek/src/megamek/common/enums/SkillLevel.java b/megamek/src/megamek/common/enums/SkillLevel.java index d6eac78ceb0..c1a840006e6 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