From 6d48cba7eac711a1603445c7532db030adf57f37 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 1 Aug 2024 18:44:10 -0500 Subject: [PATCH] Fixed support score computation Ensured that the experience level is checked before computing the support score. This change prevents negative or zero experience levels from affecting the score calculation. --- MekHQ/src/mekhq/campaign/Campaign.java | 44 ++++++++++++++++---------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index 205b9ada9e..b250335dfa 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -156,14 +156,14 @@ public class Campaign implements ITechManager { // all three // OK now we have more, parts, personnel, forces, missions, and scenarios. // and more still - we're tracking DropShips and WarShips in a separate set so that we can assign units to transports - private Hangar units = new Hangar(); - private Set transportShips = new HashSet<>(); - private Map personnel = new LinkedHashMap<>(); + private final Hangar units = new Hangar(); + private final Set transportShips = new HashSet<>(); + private final Map personnel = new LinkedHashMap<>(); private Warehouse parts = new Warehouse(); - private TreeMap forceIds = new TreeMap<>(); - private TreeMap missions = new TreeMap<>(); - private TreeMap scenarios = new TreeMap<>(); - private Map> kills = new HashMap<>(); + private final TreeMap forceIds = new TreeMap<>(); + private final TreeMap missions = new TreeMap<>(); + private final TreeMap scenarios = new TreeMap<>(); + private final Map> kills = new HashMap<>(); private transient final UnitNameTracker unitNameTracker = new UnitNameTracker(); @@ -179,8 +179,8 @@ public class Campaign implements ITechManager { // I need to put a basic game object in campaign so that I can // assign it to the entities, otherwise some entity methods may get NPE // if they try to call up game options - private Game game; - private Player player; + private final Game game; + private final Player player; private GameOptions gameOptions; @@ -190,14 +190,14 @@ public class Campaign implements ITechManager { // hierarchically structured Force object to define TO&E private Force forces; - private Hashtable lances; // AtB + private final Hashtable lances; // AtB private Faction faction; private int techFactionCode; private String retainerEmployerCode; // AtB private RankSystem rankSystem; - private ArrayList currentReport; + private final ArrayList currentReport; private transient String currentReportHTML; private transient List newReports; @@ -219,11 +219,11 @@ public class Campaign implements ITechManager { private CurrentLocation location; - private News news; + private final News news; - private PartsStore partsStore; + private final PartsStore partsStore; - private List customs; + private final List customs; private CampaignOptions campaignOptions; private RandomSkillPreferences rskillPrefs = new RandomSkillPreferences(); @@ -251,7 +251,7 @@ public class Campaign implements ITechManager { private LocalDate shipSearchExpiration; //AtB private IUnitGenerator unitGenerator; private IUnitRating unitRating; - private CampaignSummary campaignSummary; + private final CampaignSummary campaignSummary; private final Quartermaster quartermaster; private StoryArc storyArc; @@ -3497,12 +3497,22 @@ public void processNewDayPersonnel() { int score = 0; if (p.getPrimaryRole().isSupport(true)) { - score = Compute.d6(p.getExperienceLevel(this, false)); + int dice = p.getExperienceLevel(this, false); + + if (dice > 0) { + score = Compute.d6(dice); + } + multiplier += 0.5; } if (p.getSecondaryRole().isSupport(true)) { - score += Compute.d6(p.getExperienceLevel(this, false)); + int dice = p.getExperienceLevel(this, true); + + if (dice > 0) { + score += Compute.d6(dice); + } + multiplier += 0.5; } else if (p.getSecondaryRole().isNone()) { multiplier += 0.5;