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

Fix Typo and Added null check in RetirementDefectionTracker #5242

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
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 @@ -25,4 +25,4 @@ founder.text=Founder
shares.text=Shares
administrativeStrain.text=Admin Strain
managementSkill.text=Management Skill
recentpromotion.text=Recently Promoted
recentPromotion.text=Recently Promoted
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@
*/
package mekhq.campaign.personnel.turnoverAndRetention;

import static mekhq.campaign.personnel.Person.getLoyaltyName;
import static mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker.Payout.isBreakingContract;

import java.io.PrintWriter;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import megamek.codeUtilities.MathUtility;
import megamek.common.Compute;
import megamek.common.TargetRoll;
Expand All @@ -55,6 +42,18 @@
import mekhq.campaign.universe.Faction;
import mekhq.campaign.universe.FactionHints;
import mekhq.utilities.MHQXMLUtility;
import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.io.PrintWriter;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;

import static mekhq.campaign.personnel.Person.getLoyaltyName;
import static mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker.Payout.isBreakingContract;

/**
* @author Neoancient
Expand Down Expand Up @@ -177,10 +176,12 @@ public Map<UUID, TargetRoll> getTargetNumbers(final @Nullable Mission mission, f
LocalDate today = campaign.getLocalDate();
LocalDate lastPromotionDate = person.getLastRankChangeDate();

long monthsBetween = ChronoUnit.MONTHS.between(lastPromotionDate, today);
if (lastPromotionDate != null) {
long monthsBetween = ChronoUnit.MONTHS.between(lastPromotionDate, today);

if (monthsBetween <= 6) {
targetNumber.addModifier(- 1, resources.getString("recentpromotion.text"));
if (monthsBetween <= 6) {
targetNumber.addModifier(-1, resources.getString("recentPromotion.text"));
}
}
}

Expand Down