-
Notifications
You must be signed in to change notification settings - Fork 188
Refactor StratCon Reinforcement Logic and Improve Skill Checks #6709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
HammerGS
merged 4 commits into
MegaMek:master
from
IllianiBird:reinforcementAdjustments
Apr 26, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
de713d5
Refactor StratCon Reinforcement Logic and Improve Skill Checks
IllianiBird f514707
Merge branch 'master' into reinforcementAdjustments
IllianiBird 4ea573b
Merge branch 'master' into reinforcementAdjustments
IllianiBird a747dd7
- Post merge fixes
IllianiBird File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
import static megamek.common.UnitType.DROPSHIP; | ||
import static megamek.common.UnitType.JUMPSHIP; | ||
import static megamek.common.UnitType.MEK; | ||
import static megamek.common.enums.SkillLevel.REGULAR; | ||
import static mekhq.campaign.force.Force.FORCE_NONE; | ||
import static mekhq.campaign.icons.enums.OperationalStatus.determineLayeredForceIconOperationalStatus; | ||
import static mekhq.campaign.mission.AtBDynamicScenarioFactory.finalizeScenario; | ||
|
@@ -50,7 +51,6 @@ | |
import static mekhq.campaign.mission.ScenarioMapParameters.MapLocation.SpecificGroundTerrain; | ||
import static mekhq.campaign.personnel.skills.SkillType.S_ADMIN; | ||
import static mekhq.campaign.personnel.skills.SkillType.S_TACTICS; | ||
import static mekhq.campaign.personnel.skills.SkillType.getSkillHash; | ||
import static mekhq.campaign.stratcon.StratconContractInitializer.getUnoccupiedCoords; | ||
import static mekhq.campaign.stratcon.StratconRulesManager.ReinforcementEligibilityType.AUXILIARY; | ||
import static mekhq.campaign.stratcon.StratconRulesManager.ReinforcementResultsType.DELAYED; | ||
|
@@ -72,7 +72,6 @@ | |
import megamek.common.Minefield; | ||
import megamek.common.TargetRoll; | ||
import megamek.common.annotations.Nullable; | ||
import megamek.common.enums.SkillLevel; | ||
import megamek.common.event.Subscribe; | ||
import megamek.logging.MMLogger; | ||
import mekhq.MHQConstants; | ||
|
@@ -106,7 +105,7 @@ | |
import mekhq.campaign.mission.resupplyAndCaches.StarLeagueCache.CacheType; | ||
import mekhq.campaign.personnel.Person; | ||
import mekhq.campaign.personnel.skills.Skill; | ||
import mekhq.campaign.personnel.skills.SkillType; | ||
import mekhq.campaign.personnel.skills.SkillCheckUtility; | ||
import mekhq.campaign.personnel.turnoverAndRetention.Fatigue; | ||
import mekhq.campaign.stratcon.StratconContractDefinition.StrategicObjectiveType; | ||
import mekhq.campaign.stratcon.StratconScenario.ScenarioState; | ||
|
@@ -1687,7 +1686,7 @@ public static ReinforcementResultsType processReinforcementDeployment(Force forc | |
int interceptionRoll = randomInt(100); | ||
|
||
// Check passed | ||
if (interceptionRoll >= interceptionOdds) { | ||
if (interceptionRoll >= interceptionOdds || contract.getMoraleLevel().isRouted()) { | ||
reportStatus.append(' '); | ||
reportStatus.append(String.format(resources.getString("reinforcementsCommandFailure.text"), | ||
spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorWarningHexColor()), | ||
|
@@ -1696,16 +1695,6 @@ public static ReinforcementResultsType processReinforcementDeployment(Force forc | |
return DELAYED; | ||
} | ||
|
||
// Check failed, but enemy is routed | ||
if (contract.getMoraleLevel().isRouted()) { | ||
reportStatus.append(' '); | ||
reportStatus.append(String.format(resources.getString("reinforcementsSuccessRouted.text"), | ||
spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorPositiveHexColor()), | ||
CLOSING_SPAN_TAG)); | ||
campaign.addReport(reportStatus.toString()); | ||
return SUCCESS; | ||
} | ||
|
||
// Check failed, enemy attempt interception | ||
reportStatus.append(' '); | ||
reportStatus.append(String.format(resources.getString("reinforcementsInterceptionAttempt.text"), | ||
|
@@ -1738,31 +1727,23 @@ public static ReinforcementResultsType processReinforcementDeployment(Force forc | |
return FAILED; | ||
} | ||
|
||
campaign.addReport(reportStatus.toString()); | ||
|
||
|
||
roll = d6(2); | ||
int targetNumber = 9; | ||
Skill tactics = commander.getSkill(S_TACTICS); | ||
|
||
if (tactics != null) { | ||
targetNumber -= tactics.getFinalSkillValue(commander.getOptions()); | ||
} else { | ||
// Effectively a -1 penalty for being unskilled | ||
targetNumber++; | ||
} | ||
SkillCheckUtility skillCheckUtility = new SkillCheckUtility(commander, S_TACTICS, null, 0, true, false); | ||
campaign.addReport(skillCheckUtility.getResultsText()); | ||
|
||
if (roll >= targetNumber) { | ||
reportStatus.append(' '); | ||
if (skillCheckUtility.isSuccess()) { | ||
String reportString = tactics != null ? | ||
resources.getString("reinforcementEvasionSuccessful.text") : | ||
resources.getString("reinforcementEvasionSuccessful.noSkill"); | ||
reportStatus.append(String.format(reportString, | ||
campaign.addReport(String.format(reportString, | ||
spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorPositiveHexColor()), | ||
Comment on lines
+1738
to
1745
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Consider standardizing the reporting approach by either accumulating messages in reportStatus or using campaign.addReport consistently, to ensure clarity in the report output. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
CLOSING_SPAN_TAG, | ||
roll, | ||
targetNumber)); | ||
|
||
|
||
campaign.addReport(reportStatus.toString()); | ||
CLOSING_SPAN_TAG)); | ||
|
||
if (campaign.getCampaignOptions().isUseFatigue()) { | ||
increaseFatigue(force.getId(), campaign); | ||
|
@@ -1771,13 +1752,11 @@ public static ReinforcementResultsType processReinforcementDeployment(Force forc | |
return DELAYED; | ||
} | ||
|
||
reportStatus.append(' '); | ||
reportStatus.append(String.format(resources.getString("reinforcementEvasionUnsuccessful.text"), | ||
campaign.addReport(String.format(resources.getString("reinforcementEvasionUnsuccessful.text"), | ||
spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorNegativeHexColor()), | ||
CLOSING_SPAN_TAG, | ||
roll, | ||
targetNumber)); | ||
campaign.addReport(reportStatus.toString()); | ||
|
||
ScenarioTemplate scenarioTemplate = getInterceptionScenarioTemplate(force, campaign.getHangar()); | ||
|
||
|
@@ -1869,35 +1848,26 @@ private static ScenarioTemplate getInterceptionScenarioTemplate(Force force, Han | |
*/ | ||
public static TargetRoll calculateReinforcementTargetNumber(@Nullable Person commandLiaison, AtBContract contract) { | ||
// Create Target Roll | ||
TargetRoll reinforcementTargetNumber = new TargetRoll(); | ||
TargetRoll reinforcementTargetNumber = new TargetRoll(7, "Base Target Number"); | ||
|
||
// Base Target Number | ||
int skillTargetNumber = 12; | ||
SkillType skillType = getSkillHash().get(S_ADMIN); | ||
if (skillType != null) { | ||
skillTargetNumber = getSkillHash().get(S_ADMIN).getTarget(); | ||
} | ||
|
||
if (commandLiaison != null) { | ||
Skill skill = commandLiaison.getSkill(S_ADMIN); | ||
|
||
if (skill != null) { | ||
skillTargetNumber = skill.getFinalSkillValue(commandLiaison.getOptions()); | ||
} | ||
|
||
reinforcementTargetNumber.addModifier(skillTargetNumber, | ||
"Administration (" + commandLiaison.getFullTitle() + ')'); | ||
Skill skill = commandLiaison != null ? commandLiaison.getSkill(S_ADMIN) : null; | ||
int skillModifier; | ||
if (skill == null) { | ||
skillModifier = -REGULAR.getExperienceLevel(); | ||
} else { | ||
reinforcementTargetNumber.addModifier(skillTargetNumber, "Administration (Unskilled)"); | ||
skillModifier = skill.getExperienceLevel() - REGULAR.getExperienceLevel(); | ||
} | ||
|
||
// Admin Skill Modifier | ||
reinforcementTargetNumber.addModifier(skillModifier, "Administration Skill"); | ||
|
||
// Enemy Morale Modifier | ||
reinforcementTargetNumber.addModifier(contract.getMoraleLevel().ordinal(), "Enemy Morale"); | ||
|
||
// Skill Modifier | ||
int skillModifier = contract.getEnemySkill().getAdjustedValue() - SkillLevel.REGULAR.getAdjustedValue(); | ||
|
||
reinforcementTargetNumber.addModifier(skillModifier, "Enemy Skill Modifier"); | ||
int enemySkillModifier = contract.getEnemySkill().getAdjustedValue() - REGULAR.getAdjustedValue(); | ||
reinforcementTargetNumber.addModifier(enemySkillModifier, "Enemy Skill Modifier"); | ||
|
||
// Liaison Modifier | ||
ContractCommandRights commandRights = contract.getCommandRights(); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify that combining the interception roll check with the enemy morale routed condition is intentional, as this change may bypass some reporting or handling scenarios previously managed separately.
Copilot uses AI. Check for mistakes.