Skip to content

Commit

Permalink
Refined objective handling and enhanced scenario highlights
Browse files Browse the repository at this point in the history
Added strategic objective consideration to StratCon rule evaluations, ensuring attached unit modifiers and turning points trigger when applicable. Improved ScenarioTableModel by visually distinguishing objectives and turning points using specific icons and custom HTML styling.
  • Loading branch information
IllianiCBT committed Jan 23, 2025
1 parent fea135d commit 2af86fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
8 changes: 5 additions & 3 deletions MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -686,23 +686,25 @@ private static void determineIfTurningPointScenario(AtBContract contract, Stratc
return;
}

boolean isObjective = scenario.isStrategicObjective();

if (template == null || !template.getStratConScenarioType().isResupply()) {
ContractCommandRights commandRights = contract.getCommandRights();
switch (commandRights) {
case INTEGRATED -> {
scenario.setTurningPoint(true);
if (randomInt(3) == 0) {
if (randomInt(3) == 0 || isObjective) {
setAttachedUnitsModifier(scenario, contract);
}
}
case HOUSE, LIAISON -> {
if (randomInt(3) == 0) {
if (randomInt(3) == 0 || isObjective) {
scenario.setTurningPoint(true);
setAttachedUnitsModifier(scenario, contract);
}
}
case INDEPENDENT -> {
if (randomInt(3) == 0) {
if (randomInt(3) == 0 || isObjective) {
scenario.setTurningPoint(true);
}
}
Expand Down
21 changes: 18 additions & 3 deletions MekHQ/src/mekhq/gui/model/ScenarioTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Objects;
import java.util.ResourceBundle;

import static mekhq.campaign.mission.enums.ScenarioStatus.CURRENT;
import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG;
import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor;

Expand Down Expand Up @@ -114,16 +115,30 @@ public Object getValueAt(int row, int col) {
if (col == COL_NAME) {
if (campaign.getCampaignOptions().isUseStratCon()) {
if (scenario instanceof AtBScenario) {
if (scenario.getStatus() != CURRENT) {
return scenario.getName();
}

StratconScenario stratconScenario = ((AtBScenario) scenario).getStratconScenario(campaign);

if (stratconScenario != null) {
boolean isTurningPoint = stratconScenario.isTurningPoint();
String openingSpan = isTurningPoint
? spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorWarningHexColor())
: "";
String closingSpan = isTurningPoint ? CLOSING_SPAN_TAG : "";
return String.format("<html>%s%s%s</html", openingSpan,
scenario.getName(), closingSpan);

String colorblindHelper = isTurningPoint ? " \u26A0" : "";

boolean isObjective = stratconScenario.isStrategicObjective();
openingSpan = isObjective
? spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorNegativeHexColor())
: openingSpan;
colorblindHelper += isObjective ? " \u26A1" : "";

String closingSpan = isTurningPoint || isObjective ? CLOSING_SPAN_TAG : "";

return String.format("<html>%s%s%s%s</html", openingSpan,
scenario.getName(), closingSpan, colorblindHelper);
}
}
}
Expand Down

0 comments on commit 2af86fa

Please sign in to comment.