From bbd257abcd4d9fde36f602e41f5d2c343b005f54 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 26 Aug 2024 20:01:49 -0500 Subject: [PATCH] Refactored Difficulty Multiplier Calculation Revised the `getDifficultyMultiplier` method to use a switch expression based on skill levels. This change improves readability and allows for more granular control over the difficulty multipliers. --- .../mission/AtBDynamicScenarioFactory.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index 11f600d817..9a71d999cd 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -2319,16 +2319,21 @@ public static int calculateEffectiveUnitCount(AtBDynamicScenario scenario, Campa } /** - * Helper function that calculates the BV budget multiplier based on AtB skill level - * @param c - * @return - */ - private static double getDifficultyMultiplier(Campaign c) { - // skill level is between Ultra-Green (0) and Legendary (6), with Elite being the highest - // primary skill level. - // We want a number between 0.8 and 1.2 for the primary skill levels, so the formula is: - // 1 + ((skill level - 2) / 10) - return 1.0 + ((c.getCampaignOptions().getSkillLevel().getAdjustedValue() - 2) * 0.1); + * Calculates the difficulty multiplier based on campaign options. + * + * @param campaign the campaign for which to calculate the difficulty multiplier + * @return the difficulty multiplier + */ + private static double getDifficultyMultiplier(Campaign campaign) { + return switch (campaign.getCampaignOptions().getSkillLevel()) { + case NONE, ULTRA_GREEN -> 0.5; + case GREEN -> 0.75; + case REGULAR -> 1.0; + case VETERAN -> 1.25; + case ELITE -> 1.5; + case HEROIC -> 1.75; + case LEGENDARY -> 2.0; + }; } /**