Skip to content

Commit

Permalink
Merge pull request MegaMek#5242 from IllianiCBT/turnover_promotionNPE
Browse files Browse the repository at this point in the history
Fix Typo and Added `null` check in `RetirementDefectionTracker`
  • Loading branch information
IllianiCBT authored Nov 24, 2024
2 parents ae256a5 + 580dec2 commit ff3ffec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
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

0 comments on commit ff3ffec

Please sign in to comment.