Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved StratConSkillGenerator #6021

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
*/
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 {
/**
Expand All @@ -35,35 +33,32 @@ 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);
int roll = Compute.d6(1);

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);
};
if (roll == 1) {
skillLevel--;
} else if (roll == 6) {
skillLevel++;
}

skillLevel += determineBonus(entity, clanPilot, forceClan);

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)]);
}
}