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

Fixing LAM Pilot Skill Level Calculation #2586

Merged
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
24 changes: 12 additions & 12 deletions MekHQ/src/mekhq/campaign/personnel/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -2336,28 +2336,28 @@ public int getExperienceLevel(boolean secondary) {
case LAM_PILOT:
if (Stream.of(SkillType.S_GUN_MECH, SkillType.S_PILOT_MECH,
SkillType.S_GUN_AERO, SkillType.S_PILOT_AERO).allMatch(this::hasSkill)) {
int rawScore = (int) Math.floor((Stream.of(SkillType.S_GUN_MECH, SkillType.S_PILOT_MECH,
SkillType.S_GUN_AERO, SkillType.S_PILOT_AERO).mapToInt(s -> getSkill(s).getLevel()).sum())
/ 4.0
);
/*
* Attempt to use higher precision averaging, but if it doesn't provide a clear result
* due to non-standard experience thresholds then fall back on lower precision averaging
* See Bug #140
*/
if (campaign.getCampaignOptions().useAlternativeQualityAveraging()) {
if ((getSkill(SkillType.S_GUN_MECH).getType().getExperienceLevel(rawScore)
== getSkill(SkillType.S_PILOT_MECH).getType().getExperienceLevel(rawScore))
&& (getSkill(SkillType.S_GUN_MECH).getType().getExperienceLevel(rawScore)
== getSkill(SkillType.S_PILOT_AERO).getType().getExperienceLevel(rawScore))
&& (getSkill(SkillType.S_GUN_AERO).getType().getExperienceLevel(rawScore)
== getSkill(SkillType.S_PILOT_AERO).getType().getExperienceLevel(rawScore))
) {
int rawScore = (int) Math.floor((Stream.of(SkillType.S_GUN_MECH, SkillType.S_PILOT_MECH,
SkillType.S_GUN_AERO, SkillType.S_PILOT_AERO).mapToInt(s -> getSkill(s).getLevel()).sum())
/ 4.0);

final int mechGunneryExperienceLevel = SkillType.lookupHash.get(SkillType.S_GUN_MECH).getExperienceLevel(rawScore);
if ((mechGunneryExperienceLevel == SkillType.lookupHash.get(SkillType.S_PILOT_MECH).getExperienceLevel(rawScore)
&& (mechGunneryExperienceLevel == SkillType.lookupHash.get(SkillType.S_GUN_AERO).getExperienceLevel(rawScore))
&& (mechGunneryExperienceLevel == SkillType.lookupHash.get(SkillType.S_PILOT_AERO).getExperienceLevel(rawScore)))) {
return getSkill(SkillType.S_GUN_MECH).getType().getExperienceLevel(rawScore);
}
}

return rawScore;
return (int) Math.floor(
(getSkill(SkillType.S_GUN_MECH).getExperienceLevel() + getSkill(SkillType.S_PILOT_MECH).getExperienceLevel()
+ getSkill(SkillType.S_GUN_AERO).getExperienceLevel() + getSkill(SkillType.S_PILOT_AERO).getExperienceLevel())
/ 4.0);
} else {
return -1;
}
Expand Down