Skip to content

Commit

Permalink
Merge pull request #6004 from IllianiCBT/supportPointRefactor
Browse files Browse the repository at this point in the history
Refactored Support Point Modification Method Name
  • Loading branch information
IllianiCBT authored Feb 8, 2025
2 parents 212f221 + 60b5130 commit 71abc49
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/mission/AtBContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ public void checkEvents(Campaign campaign) {

if (campaignState != null) {
text += ": -1 Support Point";
campaignState.addSupportPoints(-1);
campaignState.changeSupportPoints(-1);
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024 - The MegaMek Team. All Rights Reserved.
* Copyright (c) 2019-2025 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MekHQ.
*
Expand Down Expand Up @@ -399,7 +399,7 @@ private String processObjectiveEffect(Campaign campaign, ObjectiveEffect effect,
if (dryRun) {
return String.format("%d support points will be added", numSupportPoints);
} else {
contract.getStratconCampaignState().addSupportPoints(numSupportPoints);
contract.getStratconCampaignState().changeSupportPoints(numSupportPoints);
}
}
}
Expand Down
18 changes: 15 additions & 3 deletions MekHQ/src/mekhq/campaign/stratcon/StratconCampaignState.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024 - The MegaMek Team. All Rights Reserved.
* Copyright (c) 2019-2025 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MekHQ.
*
Expand Down Expand Up @@ -131,8 +131,20 @@ public int getSupportPoints() {
return supportPoints;
}

public void addSupportPoints(int number) {
supportPoints += number;
/**
* Modifies the current support points by the specified amount.
*
* <p>
* This method increases or decreases the support points by the given number.
* It adds the value of {@code change} to the existing support points total.
* This can be used to reflect changes due to various gameplay events or actions.
* </p>
*
* @param change The amount to adjust the support points by. Positive values will
* increase the support points, while negative values will decrease them.
*/
public void changeSupportPoints(int change) {
supportPoints += change;
}

public void setSupportPoints(int supportPoints) {
Expand Down
6 changes: 3 additions & 3 deletions MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024 - The MegaMek Team. All Rights Reserved.
* Copyright (c) 2019-2025 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MekHQ.
*
Expand Down Expand Up @@ -1224,7 +1224,7 @@ private static void processFacilityEffects(StratconTrackState track,
StratconCampaignState campaignState, boolean isStartOfMonth) {
for (StratconFacility facility : track.getFacilities().values()) {
if (isStartOfMonth) {
campaignState.addSupportPoints(facility.getMonthlySPModifier());
campaignState.changeSupportPoints(facility.getMonthlySPModifier());
}
}
}
Expand Down Expand Up @@ -2652,7 +2652,7 @@ public static void processScenarioCompletion(ResolveScenarioTracker tracker) {
/**
* Processes completion of a Stratcon scenario that is linked to another scenario
* pulls forces off completed scenario and moves them to linked one.
*
*
* Should only be used after a scenario is resolved
*/
public static void linkedScenarioProcessing(ResolveScenarioTracker tracker, List<Integer> forces) {
Expand Down
20 changes: 19 additions & 1 deletion MekHQ/src/mekhq/campaign/stratcon/SupportPointNegotiation.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2024-2025 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MekHQ.
*
* MekHQ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MekHQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MekHQ. If not, see <http://www.gnu.org/licenses/>.
*/
package mekhq.campaign.stratcon;

import megamek.common.Compute;
Expand Down Expand Up @@ -159,7 +177,7 @@ private static void processContractSupportPoints(Campaign campaign, AtBContract

// Add points to the contract if positive
if (negotiatedSupportPoints > 0) {
campaignState.addSupportPoints(negotiatedSupportPoints);
campaignState.changeSupportPoints(negotiatedSupportPoints);
}

// Add a report
Expand Down
4 changes: 2 additions & 2 deletions MekHQ/src/mekhq/gui/stratcon/CampaignManagementDialog.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 - The MegaMek Team. All Rights Reserved.
* Copyright (c) 2021-2025 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MekHQ.
*
Expand Down Expand Up @@ -160,7 +160,7 @@ private void gmAddVPHandler(ActionEvent e) {
}

private void gmAddSPHandler(ActionEvent e) {
currentCampaignState.addSupportPoints(1);
currentCampaignState.changeSupportPoints(1);
btnGMRemoveSP.setEnabled(currentCampaignState.getSupportPoints() > 0);
parent.updateCampaignState();
}
Expand Down

0 comments on commit 71abc49

Please sign in to comment.