Skip to content

Commit

Permalink
Merge pull request #4346 from IllianiCBT/turnover_commanderLeadershipBug
Browse files Browse the repository at this point in the history
Refactored management skill calculation in RetirementDefectionTracker
  • Loading branch information
IllianiCBT authored Jul 7, 2024
2 parents a36d3e1 + b70b5ba commit 17540c4
Showing 1 changed file with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,10 @@ public Map<UUID, TargetRoll> getTargetNumbers(final @Nullable Mission mission, f
modifier -= campaign.getFlaggedCommander().getSkill(SkillType.S_LEADER).getFinalSkillValue();
}
} else {
// unlike commander leadership only, this already factors in the base modifier
modifier = getManagementSkillModifier(person);
modifier -= getManagementSkillModifier(person);
}

targetNumber.addModifier(- modifier, resources.getString("managementSkill.text"));
targetNumber.addModifier(modifier, resources.getString("managementSkill.text"));
}

// Shares Modifiers
Expand Down Expand Up @@ -444,9 +443,9 @@ private static int getManagementSkillModifier(Person person) {
}

if (person.getSecondaryRole() == PersonnelRole.NONE) {
return -getCommanderManagementSkill(person.getPrimaryRole());
return getCommanderManagementSkill(person.getPrimaryRole());
} else {
return -((getCommanderManagementSkill(person.getPrimaryRole()) + getCommanderManagementSkill(person.getSecondaryRole())) / 2);
return ((getCommanderManagementSkill(person.getPrimaryRole()) + getCommanderManagementSkill(person.getSecondaryRole())) / 2);
}
}

Expand Down Expand Up @@ -491,8 +490,6 @@ private static int getCommanderManagementSkill(PersonnelRole role) {
* @param campaign The Campaign object for which to calculate the management skill values.
*/
private void getManagementSkillValues(Campaign campaign) {
int baseModifier = campaign.getCampaignOptions().getManagementSkillPenalty();

for (Person person : campaign.getActivePersonnel()) {
if ((person.getPrimaryRole().isCivilian())
|| (person.getPrisonerStatus().isPrisoner())
Expand All @@ -504,49 +501,49 @@ private void getManagementSkillValues(Campaign campaign) {
case AEROSPACE:
if (person.outRanksUsingSkillTiebreaker(campaign, asfCommander)) {
asfCommander = person;
asfCommanderModifier = baseModifier - getIndividualCommanderLeadership(asfCommander);
asfCommanderModifier = getIndividualCommanderLeadership(asfCommander);
}
break;
case VEHICLE:
if (person.outRanksUsingSkillTiebreaker(campaign, vehicleCrewCommander)) {
vehicleCrewCommander = person;
vehicleCrewCommanderModifier = baseModifier - getIndividualCommanderLeadership(vehicleCrewCommander);
vehicleCrewCommanderModifier = getIndividualCommanderLeadership(vehicleCrewCommander);
}
break;
case INFANTRY:
if (person.outRanksUsingSkillTiebreaker(campaign, infantryCommander)) {
infantryCommander = person;
infantryCommanderModifier = baseModifier - getIndividualCommanderLeadership(infantryCommander);
infantryCommanderModifier = getIndividualCommanderLeadership(infantryCommander);
}
break;
case NAVAL:
if (person.outRanksUsingSkillTiebreaker(campaign, navalCommander)) {
navalCommander = person;
navalCommanderModifier = baseModifier - getIndividualCommanderLeadership(navalCommander);
navalCommanderModifier = getIndividualCommanderLeadership(navalCommander);
}
break;
case TECH:
if (person.outRanksUsingSkillTiebreaker(campaign, techCommander)) {
techCommander = person;
techCommanderModifier = baseModifier - getIndividualCommanderLeadership(techCommander);
techCommanderModifier = getIndividualCommanderLeadership(techCommander);
}
break;
case MEDICAL:
if (person.outRanksUsingSkillTiebreaker(campaign, medicalCommander)) {
medicalCommander = person;
medicalCommanderModifier = baseModifier - getIndividualCommanderLeadership(medicalCommander);
medicalCommanderModifier = getIndividualCommanderLeadership(medicalCommander);
}
break;
case ADMINISTRATOR:
if (person.outRanksUsingSkillTiebreaker(campaign, administrationCommander)) {
administrationCommander = person;
administrationCommanderModifier = baseModifier - getIndividualCommanderLeadership(administrationCommander);
administrationCommanderModifier = getIndividualCommanderLeadership(administrationCommander);
}
break;
case MECHWARRIOR:
if (person.outRanksUsingSkillTiebreaker(campaign, mechWarriorCommander)) {
mechWarriorCommander = person;
mechWarriorCommanderModifier = baseModifier - getIndividualCommanderLeadership(mechWarriorCommander);
mechWarriorCommanderModifier = getIndividualCommanderLeadership(mechWarriorCommander);
}
break;
case CIVILIAN:
Expand All @@ -558,42 +555,42 @@ private void getManagementSkillValues(Campaign campaign) {
switch (profession) {
case AEROSPACE:
if (asfCommander == null) {
asfCommanderModifier = baseModifier;
asfCommanderModifier = 0;
}
break;
case VEHICLE:
if (vehicleCrewCommander == null) {
vehicleCrewCommanderModifier = baseModifier;
vehicleCrewCommanderModifier = 0;
}
break;
case INFANTRY:
if (infantryCommander == null) {
infantryCommanderModifier = baseModifier;
infantryCommanderModifier = 0;
}
break;
case NAVAL:
if (navalCommander == null) {
navalCommanderModifier = baseModifier;
navalCommanderModifier = 0;
}
break;
case TECH:
if (techCommander == null) {
techCommanderModifier = baseModifier;
techCommanderModifier = 0;
}
break;
case MEDICAL:
if (medicalCommander == null) {
medicalCommanderModifier = baseModifier;
medicalCommanderModifier = 0;
}
break;
case ADMINISTRATOR:
if (administrationCommander == null) {
administrationCommanderModifier = baseModifier;
administrationCommanderModifier = 0;
}
break;
case MECHWARRIOR:
if (mechWarriorCommander == null) {
mechWarriorCommanderModifier = baseModifier;
mechWarriorCommanderModifier = 0;
}
break;
case CIVILIAN:
Expand Down

0 comments on commit 17540c4

Please sign in to comment.