Skip to content

Commit

Permalink
Merge pull request #2586 from Windchild292/dev_Windchild_LAMPilotSkil…
Browse files Browse the repository at this point in the history
…lLevel

Fixing LAM Pilot Skill Level Calculation
  • Loading branch information
Windchild292 authored May 9, 2021
2 parents 86c06fa + e847e4d commit ccf55cc
Showing 1 changed file with 12 additions and 12 deletions.
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

0 comments on commit ccf55cc

Please sign in to comment.