Skip to content

Commit

Permalink
Refactored patrol scenario assignment logic
Browse files Browse the repository at this point in the history
Revised patrol logic to clarify conditions for relocating scenarios and auto-assigning lances. Replaced "isRecon" with "isPatrol" for better readability and adjusted related condition checks. Streamlined scenario generation by migrating patrols to unoccupied adjacent coordinates when not targeting facilities.
  • Loading branch information
IllianiCBT committed Jan 8, 2025
1 parent 4964496 commit e5ee002
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static void generateScenariosDatesForWeek(Campaign campaign, StratconCamp
break;
}

if (autoAssignLances && (campaignState.getWeeklyScenarios().size() >= availableForceIDs.size())) {
if (autoAssignLances && (scenarioIndex >= availableForceIDs.size())) {
break;
}

Expand Down Expand Up @@ -960,7 +960,7 @@ public static void deployForceToCoords(StratconCoords coords, int forceID, Campa
return;
}

boolean isRecon = combatTeam.getRole().isPatrol();
boolean isPatrol = combatTeam.getRole().isPatrol();

// the following things should happen:
// 1. call to "process force deployment", which reveals fog of war in or around the coords,
Expand All @@ -983,15 +983,6 @@ public static void deployForceToCoords(StratconCoords coords, int forceID, Campa
return;
}

if (isRecon) {
StratconCoords newCoords = getUnoccupiedAdjacentCoords(coords, track);

if (newCoords != null) {
coords = newCoords;
}
}

// don't create a scenario on top of allied facilities
StratconFacility facility = track.getFacility(coords);
boolean isNonAlliedFacility = (facility != null) && (facility.getOwner() != Allied);

Expand All @@ -1000,12 +991,23 @@ public static void deployForceToCoords(StratconCoords coords, int forceID, Campa

if (isNonAlliedFacility || spawnScenario) {
StratconScenario scenario;
boolean autoAssignLances = !isRecon;

Set<Integer> preDeployedForce = track.getAssignedCoordForces().get(coords);
// If we're not deploying on top of an enemy facility, migrate the scenario
if (!isNonAlliedFacility && isPatrol) {
StratconCoords newCoords = getUnoccupiedAdjacentCoords(coords, track);

if (newCoords != null) {
coords = newCoords;
}
}

// Patrols only get autoAssigned to the scenario if they're dropped on top of a non-allied facility
boolean autoAssignLances = !isPatrol || isNonAlliedFacility;

// Do we already have forces deployed to the target coordinates?
// If so, assign them to the scenario.
Set<Integer> preDeployedForce = track.getAssignedCoordForces().get(coords);

if (preDeployedForce != null && !preDeployedForce.isEmpty()) {
scenario = generateScenarioForExistingForces(coords,
track.getAssignedCoordForces().get(coords), contract, campaign, track);
Expand Down

0 comments on commit e5ee002

Please sign in to comment.