Skip to content
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

Updated MekHQ Morale & StratCon Scenario Spawn Methods #5243

Merged
merged 23 commits into from
Nov 24, 2024

Conversation

IllianiCBT
Copy link
Collaborator

This PR includes the non-persistent OpFor changes, from my earlier (now scrapped) PR.

This includes an update to MekHQ Morale to make it feel less random and more reflective of the actual game state. Documentation has been updated accordingly.

Contracts will no longer universally begin with Stalemate morale. Instead we will make a preliminary morale check, which may cause contracts to begin with their morale adjusted by up to 2 steps up, or down. Though most contracts will likely still begin at Stalemate.

Garrison contracts will begin at Routed with a certain number of months' peace guaranteed. This means it is no longer possible to know for certain who you will be facing when accepting a garrison contract - or if you will be fighting at all. A warning dialog appears when accepting a Garrison contract, allowing users to cancel out of accepting the contract if they don't want to take this risk.

Relief Duty contracts are more likely to have contracts start with higher than normal morale levels, potentially starting with the enemy already at Overwhelming.

On the backend side, the new methods that allow us to easily add new scenarios to StratCon tracks have been expanded and updated to be more reliable and feature complete.

Added the calculation of planetary diameter to the initialization of StratconTrackState. This allows the track size to be set proportionally based on the planet's surface area, ensuring more realistic and varied gameplay environments.
Added null checks throughout Stratcon scenario generation methods to handle potential null scenarios. Created new methods and updated existing ones to ensure robust error handling and to return null if scenario creation fails.
Implemented a `getSize` method to calculate the track size based on width and height. This change enhances the functionality by providing a straightforward way to retrieve the total size of the track. Additionally, minor formatting adjustments were made for code consistency.
Added logic to seed sectors with hidden forces based on contract type in StratconContractInitializer. Differentiated scenario creation between garrison, raid, pirate hunting, and planetary assault contracts.
Modified contract generation to prevent full-scale invasions for pirate hunting contracts. Adjusted multiplier settings to treat guerrilla warfare similarly to raid types. These changes enhance the accuracy and realism of mission deployment scenarios.
Removed redundant scenario generation checks and refactored pre-deployment probability calculations. Simplified conditionals in StratconRulesManager, and integrated scenario odds computation into StratconContractInitializer. This enhances code clarity and consistency in scenario management.
Modified scenario generation to include an option for allowing scenarios to spawn on top of player-allied facilities. Updated function signatures and added logic to accommodate this new parameter, ensuring that scenarios can now be placed more flexibly based on provided configurations.
Refactored the calculation of scenario odds for better readability and maintainability. Also added a new method to handle daily movement processing for scenarios in each track. Expanded pre-deployment logic and cleaned up code to enhance functionality.
Updated the copyright years to 2024 and revised the license information for consistency and accuracy. This ensures the codebase reflects the correct legal information and adheres to the project's licensing guidelines.
Changed the visibility of the seedPreDeployedForces method to private and added a detailed Javadoc comment explaining its functionality. Removed redundant comments from the initializeTrackState method to improve code readability.
Made `seedPreDeployedForces` method public to allow seeding of pre-deployed forces in StratCon tracks. Also added logic to handle pre-deployment for garrison and pirate hunting contract types.
PreSeeded enemy force count is now based on enemy quality and faction.
Introduced a new method, `processMassRout`, in `StratconRulesManager` to handle scenarios without deployment dates. Integrated this method into `AtBContract` to ensure these scenarios are removed and updated appropriately.
Ensured that mass rout processing in AtBContract only occurs when StratCon is enabled in campaign options. This change prevents unnecessary operations and aligns with the intended functionality of user-defined campaign options.
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.
Modified `getUnoccupiedAdjacentCoords` method to include an optional boolean parameter `weightPlayerForces` which prioritizes player-allied forces and facilities when determining suitable adjacent coordinates. Updated `StratconRulesManager` to leverage this new parameter for enhanced scenario deployment logic.
Updated the condition to exclude strategic objectives when checking for null deployment dates in scenarios. This ensures that only relevant scenarios get new coordinates, preventing strategic objectives from being relocated erroneously.
Improved the morale calculation and routing logic when handling contracts, especially garrison duties. Updated methods to factor in enemy skill, weapon reliability, and included a more sophisticated approach to determining balance of power. Minor refactoring was also done for code clarity and efficiency.
# Conflicts:
#	MekHQ/resources/mekhq/resources/Campaign.properties
Adjusted performance modifier calculation to include tightened conditions for victory and defeat ratios. Modified the decrease and increase values to better reflect performance variability.
Updated the morale initialization logic to differentiate between garrison and relief duty contracts. Utilized the 'min' function to adjust morale levels more accurately and corrected a typo in the contract type check.
@IllianiCBT IllianiCBT added StratCon Bugs relating strictly to StratCon Refactoring Documentation labels Nov 24, 2024
@IllianiCBT IllianiCBT self-assigned this Nov 24, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.50%. Comparing base (580dec2) to head (519101f).
Report is 90 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5243      +/-   ##
============================================
- Coverage     10.50%   10.50%   -0.01%     
- Complexity     6039     6044       +5     
============================================
  Files           957      957              
  Lines        134609   134716     +107     
  Branches      19535    19572      +37     
============================================
+ Hits          14147    14149       +2     
- Misses       119106   119216     +110     
+ Partials       1356     1351       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@IllianiCBT IllianiCBT merged commit 696f5e7 into MegaMek:master Nov 24, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Refactoring StratCon Bugs relating strictly to StratCon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants