Skip to content

Commit

Permalink
Remove redundant logging and simplify condition handling
Browse files Browse the repository at this point in the history
Removed an unnecessary log statement that printed the force name. Simplified the conditional check for reinforcement restrictions, ensuring better readability and maintainability.
  • Loading branch information
IllianiCBT committed Nov 25, 2024
1 parent 5b00e18 commit 5cf9b56
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
21 changes: 10 additions & 11 deletions MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1459,20 +1459,19 @@ public static List<Integer> getAvailableForceIDs(int unitType, Campaign campaign
continue;
}

logger.info(force.getName());

int primaryUnitType = force.getPrimaryUnitType(campaign);
boolean noReinforcementRestriction = !reinforcements || (reinforcements
&& (getReinforcementType(force.getId(), currentTrack, campaign,
campaignState) != ReinforcementEligibilityType.None));
if ((force.getScenarioId() <= 0) && !force.getAllUnits(true).isEmpty()
&& !forcesInTracks.contains(force.getId())
&& forceCompositionMatchesDeclaredUnitType(primaryUnitType, unitType, reinforcements)
&& noReinforcementRestriction
&& !subElementsOrSelfDeployed(force, campaign)) {
boolean noReinforcementRestriction = !reinforcements ||
(getReinforcementType(force.getId(), currentTrack, campaign, campaignState) != ReinforcementEligibilityType.None);

if ((force.getScenarioId() <= 0)
&& !force.getAllUnits(true).isEmpty()
&& !forcesInTracks.contains(force.getId())
&& forceCompositionMatchesDeclaredUnitType(primaryUnitType, unitType, reinforcements)
&& noReinforcementRestriction
&& !subElementsOrSelfDeployed(force, campaign)) {

retVal.add(force.getId());
}
retVal.add(force.getId());
}

return retVal;
Expand Down
14 changes: 9 additions & 5 deletions MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,18 @@ public void actionPerformed(ActionEvent action) {
}
gui.undeployForces(forces);
gui.getTOETab().refreshForceView();

for (Force formation : gui.getCampaign().getAllForces()) {
MekHQ.triggerEvent(new OrganizationChangedEvent(formation));
}
} else if (command.contains(CHANGE_STRATEGIC_FORCE_OVERRIDE)) {
if (singleForce == null) {
return;
}

boolean overrideState = singleForce.getOverrideStrategicFormation() == STRATEGIC_FORMATION_OVERRIDE_TRUE;
singleForce.setStrategicFormation(!overrideState);
singleForce.setOverrideStrategicFormation(!overrideState ? STRATEGIC_FORMATION_OVERRIDE_TRUE : STRATEGIC_FORMATION_OVERRIDE_FALSE);
boolean formationState = singleForce.isStrategicFormation();
singleForce.setStrategicFormation(!formationState);
singleForce.setOverrideStrategicFormation(!formationState ? STRATEGIC_FORMATION_OVERRIDE_TRUE : STRATEGIC_FORMATION_OVERRIDE_FALSE);

for (Force formation : gui.getCampaign().getAllForces()) {
MekHQ.triggerEvent(new OrganizationChangedEvent(formation));
Expand Down Expand Up @@ -1048,8 +1052,8 @@ protected Optional<JPopupMenu> createPopupMenu() {
menuItem.addActionListener(this);
popup.add(menuItem);

JMenuItem optionStrategicForceOverride = new JMenuItem(force.isStrategicFormation() ?
"Remove Strategic Formation Assignment" : "Assign as Strategic Formation");
JMenuItem optionStrategicForceOverride = new JMenuItem((force.isStrategicFormation() ?
"Never" : "Always") + " Consider Force a Strategic Formation");
optionStrategicForceOverride.setActionCommand(COMMAND_CHANGE_STRATEGIC_FORCE_OVERRIDE + forceIds);
optionStrategicForceOverride.addActionListener(this);
popup.add(optionStrategicForceOverride);
Expand Down

0 comments on commit 5cf9b56

Please sign in to comment.