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

Centralized Formation Size Logic & Adjusted Contract Required Lance Count #5280

Merged
merged 3 commits into from
Dec 4, 2024

Conversation

IllianiCBT
Copy link
Collaborator

Unified the various methods for calculating standard force sizes based on factions, enabling consistent and flexible force size determination. Formation sizes are now housed in StrategicFormation.java.

Adjusted the logic for determining how many forces a contract requires. Previously, we did some math, looking at the number of combat units in the TO&E and then doing some math. Often this would give the user a spare lance or two, but from what I can tell this was a byproduct of some math and not something that was actually enforced. Furthermore, there was no support for factions that didn't use base 4 i.e. Clans, or ComStar.

Now the base number of strategic forces required for a contract is based on faction. How this works is we scan the TO&E for combat units and then count the number of 'points' each unit contributes (based on faction preferences). We divide this number by the standard lance-level formation for the campaign faction. This part of the code is identical to the previous implementation, the only thing that we've changed is using faction lance-level size, rather than always assuming an IS base-4.

For example, if you are a Clan campaign with 10 'Meks (1 point), 5 Vees (0.5 point each), and 5 Aerospace Fighters (0.5 point each) you will be considered to have 15 points total. This will mean your base required forces is 3. I'm not going to go into the full workings here, as that code is all unchanged.

Once we have determined base force count we drop 1-in-3 forces. That means in the above example, the Clan player would only be required to provide 2 Stars, not 3. We do this so that the player always has reserve forces unless they choose to over-extend (see below).

Finally we roll 2d6 with the result adjusting the number of required forces:

 2: 25%
 3: 50%
 4: 75%
 5-9: 100%
 10: 125%
 11: 150%
 12: 175%

The number of required forces will never go below 1, or above the maximum number of deployable forces available to the campaign (again, remember we are calculating this based on the number of combat units in the TO&E not the number of explicit forces).

Contract pay is adjusted accordingly. This means the player can choose to take a less intense contract, where they know they will have plenty of reserve forces, or they can reduce the number of available reserves in exchange for a bigger payout.

Unified the method for calculating standard force sizes based on factions, enabling consistent and flexible force size determination. Replaced magic numbers with descriptive constants to improve code readability and maintainability. Simplified the process of calculating required combat forces and adjusted labels to reflect this change.
Simplified import statements by rearranging and removing unused ones, which improved code readability. Modified lance calculation logic to prevent potential zero-lance deployment by ensuring at least one lance is required. This change ensures more reliable and consistent contract setups.
@IllianiCBT IllianiCBT added the StratCon Bugs relating strictly to StratCon label Dec 3, 2024
@IllianiCBT IllianiCBT self-assigned this Dec 3, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.48%. Comparing base (d333f62) to head (0b5ea2e).
Report is 37 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5280      +/-   ##
============================================
+ Coverage     10.47%   10.48%   +0.01%     
  Complexity     6049     6049              
============================================
  Files           959      959              
  Lines        135202   135223      +21     
  Branches      19674    19682       +8     
============================================
+ Hits          14165    14181      +16     
- Misses       119686   119687       +1     
- Partials       1351     1355       +4     

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

Replaced conditional check from 'roll <= 3' to 'roll == 3' to ensure the correct scaling factor is applied for available forces. This change prevents incorrect force allocation for other values of roll greater than 3.
Copy link
Member

@HammerGS HammerGS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-Pilot sees no issues.

@HammerGS HammerGS merged commit 9adae92 into MegaMek:master Dec 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
StratCon Bugs relating strictly to StratCon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants