From 045596a960f06c9a7f438866a6a1659bb1cb290f Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Thu, 31 Oct 2024 12:07:21 -0500 Subject: [PATCH] Refactor Supply Depot SPt Modifiers to be Monthly Changed the support point modifiers gained from Supply Depot facilities from weekly to monthly. --- .../stratconfacilities/AlliedSupplyDepot.xml | 2 +- .../campaign/stratcon/StratconFacility.java | 43 +++++++++++-------- .../stratcon/StratconRulesManager.java | 9 ++-- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/MekHQ/data/stratconfacilities/AlliedSupplyDepot.xml b/MekHQ/data/stratconfacilities/AlliedSupplyDepot.xml index 1209cee42b..664fe14ab8 100644 --- a/MekHQ/data/stratconfacilities/AlliedSupplyDepot.xml +++ b/MekHQ/data/stratconfacilities/AlliedSupplyDepot.xml @@ -4,6 +4,6 @@ SupplyDepot Allied 1 - Provides 1 SP/week of allied logistical support. + Provides 1 SP/month of allied logistical support. true diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconFacility.java b/MekHQ/src/mekhq/campaign/stratcon/StratconFacility.java index 017f181246..a644e03d57 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconFacility.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconFacility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 - The MegaMek Team. All Rights Reserved. + * Copyright (c) 2020-2024 - The MegaMek Team. All Rights Reserved. * * This file is part of MekHQ. * @@ -18,14 +18,6 @@ */ package mekhq.campaign.stratcon; -import java.io.File; -import java.io.FileInputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.TreeMap; - -import javax.xml.transform.Source; - import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.Unmarshaller; @@ -34,9 +26,16 @@ import mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment; import mekhq.utilities.MHQXMLUtility; +import javax.xml.transform.Source; +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.TreeMap; + /** * This represents a facility in the StratCon context - * + * * @author NickAragua */ @XmlRootElement(name = "StratconFacility") @@ -68,7 +67,7 @@ public enum FacilityType { private String capturedDefinition; private boolean revealTrack; private int scenarioOddsModifier; - private int weeklySPModifier; + private int monthlySPModifier; private boolean preventAerospace; // TODO: post-MVP // private Map fixedGarrisonUnitStates = new HashMap<>(); @@ -96,7 +95,7 @@ public StratconFacility clone() { clone.setCapturedDefinition(capturedDefinition); clone.revealTrack = revealTrack; clone.scenarioOddsModifier = scenarioOddsModifier; - clone.weeklySPModifier = weeklySPModifier; + clone.monthlySPModifier = monthlySPModifier; clone.preventAerospace = preventAerospace; clone.userDescription = userDescription; clone.biomes = new ArrayList<>(biomes); @@ -115,7 +114,7 @@ public void copyRulesDataFrom(StratconFacility facility) { setOwner(facility.getOwner()); setRevealTrack(facility.getRevealTrack()); setScenarioOddsModifier(facility.getScenarioOddsModifier()); - setWeeklySPModifier(facility.getWeeklySPModifier()); + setMonthlySPModifier(facility.getMonthlySPModifier()); setPreventAerospace(facility.preventAerospace()); setBiomes(new ArrayList<>(facility.getBiomes())); setUserDescription(facility.getUserDescription()); @@ -254,12 +253,20 @@ public void setScenarioOddsModifier(int scenarioOddsModifier) { this.scenarioOddsModifier = scenarioOddsModifier; } - public int getWeeklySPModifier() { - return weeklySPModifier; + /** + * @return The facility's monthly SP (Support Points) modifier as an integer. + */ + public int getMonthlySPModifier() { + return monthlySPModifier; } - public void setWeeklySPModifier(int weeklySPModifier) { - this.weeklySPModifier = weeklySPModifier; + /** + * Sets a new value for the monthly SP (Support Points) modifier. + * + * @param monthlySPModifier The new monthly SP modifier value. + */ + public void setMonthlySPModifier(int monthlySPModifier) { + this.monthlySPModifier = monthlySPModifier; } /** @@ -273,7 +280,7 @@ public TreeMap getBiomeTempMap() { /** * Attempt to deserialize an instance of a StratconFacility from the passed-in * file name - * + * * @return Possibly an instance of a StratconFacility */ public static StratconFacility deserialize(String fileName) { diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index ef75b58ea2..6f68391d31 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -658,10 +658,10 @@ private static void setupFacilityScenario(StratconScenario scenario, StratconFac * Applies time-sensitive facility effects. */ private static void processFacilityEffects(StratconTrackState track, - StratconCampaignState campaignState, boolean isMonday) { + StratconCampaignState campaignState, boolean isStartOfMonth) { for (StratconFacility facility : track.getFacilities().values()) { - if (isMonday) { - campaignState.addSupportPoints(facility.getWeeklySPModifier()); + if (isStartOfMonth) { + campaignState.addSupportPoints(facility.getMonthlySPModifier()); } } } @@ -1903,6 +1903,7 @@ public void handleNewDay(NewDayEvent ev) { return; } boolean isMonday = ev.getCampaign().getLocalDate().getDayOfWeek() == DayOfWeek.MONDAY; + boolean isStartOfMonth = ev.getCampaign().getLocalDate().getDayOfMonth() == 1; // run scenario generation routine for every track attached to an active // contract @@ -1919,7 +1920,7 @@ public void handleNewDay(NewDayEvent ev) { // 0-deployment-length tracks processTrackForceReturnDates(track, ev.getCampaign()); - processFacilityEffects(track, campaignState, isMonday); + processFacilityEffects(track, campaignState, isStartOfMonth); // loop through scenarios - if we haven't deployed in time, // fail it and apply consequences