Skip to content

Commit

Permalink
Optimize StratCon handling and improve offensive definition
Browse files Browse the repository at this point in the history
Updated isOffensive method to include planetary assaults, modified processMassRout to streamline parameters, and adjusted seeding logic with revised multipliers. This enhances the clarity and efficiency of the StratCon campaign state management and scenario processing.
  • Loading branch information
IllianiCBT committed Nov 21, 2024
1 parent b961d1f commit 9db1860
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 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 @@ -543,7 +543,7 @@ public void checkMorale(Campaign campaign, LocalDate today) {
}

if (campaign.getCampaignOptions().isUseStratCon()) {
processMassRout(campaign, getStratconCampaignState());
processMassRout(getStratconCampaignState());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public boolean isRaidType() {
* {@code false} otherwise
*/
public boolean isOffensive() {
return isRaidType() || isPirateHunting() || isGuerrillaWarfare();
return isRaidType() || isPirateHunting() || isGuerrillaWarfare() || isPlanetaryAssault();
}
// endregion Boolean Comparison Methods

Expand Down
18 changes: 8 additions & 10 deletions MekHQ/src/mekhq/campaign/stratcon/StratconContractInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.List;
import java.util.Random;

import static java.lang.Math.ceil;
import static java.lang.Math.round;
import static megamek.common.Coords.ALL_DIRECTIONS;
import static mekhq.campaign.rating.IUnitRating.*;
Expand Down Expand Up @@ -221,28 +222,25 @@ public static void initializeCampaignState(AtBContract contract, Campaign campai
* @param track the relevant {@link StratconTrackState}
*/
public static void seedPreDeployedForces(AtBContract contract, Campaign campaign, StratconTrackState track) {
final int CLAN_CLUSTER = 27; // Stars
final int IS_BATTALION = 27; // Lances
final int COMSTAR_LEVEL_IV = 36; // Level IIs
// TODO remove reductions once we have friendly forces deploying too
final int CLAN_CLUSTER = 11; // 22 Stars, reduced to 11
final int IS_BATTALION = 14; // 27 Lances, reduced to 14
final int COMSTAR_LEVEL_IV = 18; // 36 Level IIs, reduced to 18

double multiplier = switch (contract.getEnemyQuality()) {
case DRAGOON_F -> 0.25;
case DRAGOON_D -> 0.5;
case DRAGOON_C -> 0.75;
case DRAGOON_B -> 1;
case DRAGOON_A -> 1.5;
case DRAGOON_ASTAR -> 2;
default ->
throw new IllegalStateException(
"Unexpected value in mekhq/campaign/stratcon/StratconContractInitializer.java/seedPreDeployedForces: "
+ contract.getEnemyQuality());
default -> 1; // DRAGOON_B
};

AtBContractType contractType = contract.getContractType();

if (contractType.isPirateHunting() || contractType.isGarrisonType()) {
multiplier *= 0.5;
} else if (contractType.isOffensive()) {
} else if (contractType.isPlanetaryAssault()) {
multiplier *= 2;
}

Expand All @@ -254,7 +252,7 @@ public static void seedPreDeployedForces(AtBContract contract, Campaign campaign
elementCount = COMSTAR_LEVEL_IV;
}

elementCount = (int) round(elementCount * multiplier);
elementCount = (int) ceil(elementCount * multiplier);

for (int i = 0; i < elementCount; i++) {
addHiddenExternalScenario(campaign, contract, track, null, false);
Expand Down
3 changes: 1 addition & 2 deletions MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2070,10 +2070,9 @@ public static void processDailyMovement(Campaign campaign, StratconCampaignState
* If scenario's deployment date is {@code null} and scenario is not a strategic objective,
* it is removed from the track and then updated.
*
* @param campaign the current campaign.
* @param campaignState the relevant StratCon campaign state.
*/
public static void processMassRout(Campaign campaign, StratconCampaignState campaignState) {
public static void processMassRout(StratconCampaignState campaignState) {
for (StratconTrackState track : campaignState.getTracks()) {
List<StratconScenario> allScenarios = new ArrayList<>(track.getScenarios().values());

Expand Down

0 comments on commit 9db1860

Please sign in to comment.