From 3ba9723620c00b6231c1d28c4557ff61945e5ecf Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 19 Sep 2024 23:55:02 -0500 Subject: [PATCH 1/2] Refactor StratConSkillGenerator skill logic Refactored the skill generation logic in StratConSkillGenerator to streamline skill level calculations and removed redundant bonus handling. Also cleaned up logging in AtBDynamicScenarioFactory and removed an unnecessary skill generator type setting. --- .../StratConSkillGenerator.java | 40 ++++++------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java b/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java index 2904248345d..466c2bc3852 100644 --- a/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java +++ b/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java @@ -18,11 +18,8 @@ */ package megamek.client.generator.skillGenerators; -import megamek.codeUtilities.MathUtility; -import megamek.common.Compute; import megamek.common.Entity; import megamek.common.LandAirMek; -import megamek.common.enums.SkillLevel; public class StratConSkillGenerator extends TotalWarfareSkillGenerator { /** @@ -35,35 +32,24 @@ public class StratConSkillGenerator extends TotalWarfareSkillGenerator { */ @Override public int[] generateRandomSkills(final Entity entity, final boolean clanPilot, final boolean forceClan) { - int bonus = switch (getLevel()) { - case ULTRA_GREEN -> 0; - case GREEN -> 1; - case VETERAN -> 3; - case ELITE -> 4; - case HEROIC -> 5; - case LEGENDARY -> 6; - default -> 2; + 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) { - bonus += 1; + skillLevel += 1; } - // this will give us a SkillLevel 1 above or below the default rate, or at the default rate - final int roll = MathUtility.clamp(Compute.randomInt(3) - 1 + bonus, 0, 6); + skillLevel += determineBonus(entity, clanPilot, forceClan); - SkillLevel skillLevel = switch (roll) { - case 0 -> SkillLevel.ULTRA_GREEN; - case 1 -> SkillLevel.GREEN; - case 2 -> SkillLevel.REGULAR; - case 3 -> SkillLevel.VETERAN; - case 4 -> SkillLevel.ELITE; - case 5 -> SkillLevel.HEROIC; - case 6 -> SkillLevel.LEGENDARY; - default -> throw new IllegalStateException("Unexpected value in megamek/client/generator/skillGenerators/StratConSkillGenerator.java/generateRandomSkills: " - + roll); - }; - - return generateRandomSkills(skillLevel, 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)]); } } From f076d31aff69bc890d0184443682770d4e203837 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 20 Sep 2024 00:47:19 -0500 Subject: [PATCH 2/2] Add random roll to skill level adjustment A random dice roll was introduced to adjust the skill level in the StratConSkillGenerator class. A roll of 1 decreases the skill level while a roll of 6 increases it. This change aims to introduce more variability to skill level determination. --- .../skillGenerators/StratConSkillGenerator.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java b/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java index 466c2bc3852..69a088dbb44 100644 --- a/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java +++ b/megamek/src/megamek/client/generator/skillGenerators/StratConSkillGenerator.java @@ -18,6 +18,7 @@ */ package megamek.client.generator.skillGenerators; +import megamek.common.Compute; import megamek.common.Entity; import megamek.common.LandAirMek; @@ -46,6 +47,14 @@ public int[] generateRandomSkills(final Entity entity, final boolean clanPilot, skillLevel += 1; } + int roll = Compute.d6(1); + + if (roll == 1) { + skillLevel--; + } else if (roll == 6) { + skillLevel++; + } + skillLevel += determineBonus(entity, clanPilot, forceClan); return cleanReturn(entity,